Question

Is it possible to highlight a list of countries with a different colors? I need to display some countries' statistics on the world map.

Now I use an image and fill a region with color (calculated for each country) by country's coordinates. It's a simple solution and it works well. But now I need to specify the countries' name too (and I think it's not the last customization).

There is a polygon solution, but it uses an array of coordinates. I don't think it's a suitable solution to highlight countries's territory.

I haven't found a solution yet. Any suggestions?

Thanks in advance.

Was it helpful?

Solution

Highlighting countries or regions to support statistics is known as Choropleth Mapping , but unfortunately there usually isn't direct library support for Choropleth maps bundled into an online map API. This means you'll have to create your own framework, but fortunately it is possible to create one - I wrote an example using jQuery + HERE Maps to answer the question here

enter image description here

Updated WKT solution now available

Access to KML shapes is no longer required, since the Geocoder API now offers an IncludeShapes attribute which returns the shape of a country in WKT format. A WKT parser can be found here. A simple WKT choropleth example can be found here.

KML Base solution

For any framework you will need to have a file holding the boundaries of the countries or regions you need. The example uses a KML file, but you could also start with polygons if you had them. Country borders are a political minefield, which is the reason I guess most online mapping APIs steer clear of them. As a hint: try starting with something like http://geocommons.com/overlays/119819 and simplify it as much as possible to speed up the rendering- many small wiggles in the coast lines and small outlying islands are unnecessary.

Of course you could also try searching for "create choropleth map" from a search engine of your choice and use an tool to create a static image for your data (potentially at several zoom levels) and then use this as the basis of an map tile overlay. This requires a lot more work up front, but would push all the calculations server side and hence be faster to display.

Working example can be found on GitHub here

OTHER TIPS

You could put the country's name into the image. It's not that difficult to place text into an image. The only tricky bit is if you are using tiles, you need to deal with names that cross tile boundaries by drawing the name once for each tile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top