We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
World Map (Read 534 times)
World Map
Feb 14th, 2008, 12:14pm
 
I want to make a simple world map, including countries.

Does anyone have any hints on how I could best achieve this? The countries have to be seperate instances / clickable. - I would presume that somebody already did something like this, but all I can find on the internet are flash-applications without source-codes.
Re: World Map
Reply #1 - Feb 14th, 2008, 1:33pm
 
I would use a SVG world map. search Wikipedia or Wikimedia, you may find the map you want in SVG format. hopefully, each country should be a separate object. then, see Processing's libraries, there's one to display SVG drawings.

to make each country clickable, you can use an image buffer and a simple picking method. draw each country in the buffer in a different color, then when the user clicks, check the color in the buffer, and you'll get the country. have a look to Processing Hacks > Picking if you want more info. hope it helps.
Re: World Map
Reply #2 - Feb 14th, 2008, 1:40pm
 
Then I would have 1 more problem; linking the names (and data) to the several countries.

I want to make a map that shows the different wars and conflicts around the world, and onmouseover which countries are invested in the conflict.
Re: World Map
Reply #3 - Feb 14th, 2008, 2:20pm
 
the simplest way is to create a Country class describing all the data you want to associate to the countries : name, shape, display color, buffer color, etc. Something like this :

Code:
class Country {
SVG shape;
int x, y;
String name;
color bufferColor;
}


once you've created each country, you can put all of them in an array, and you'll get your world map. iterate the array and call shape.draw(x, y) to display the countries on screen.

you can treat wars/conflicts as arrays of countries. on mouseOver, check if the selected country belongs to one or another array, and see the other countries concerned by this war/conflict by iterating the array.
Page Index Toggle Pages: 1