4
votes

I am using Mapbox to build a multiple choropleth map. Something along the lines of this example, https://www.mapbox.com/mapbox.js/example/v1.0.0/choropleth-joined-data-multiple-variables/

I am using countries instead of US states however. I've got the map working and I can switch between layers I have an extra requirement however to add a marker in each country that displays how many projects are active in that country. I found out how I can add custom markers to the map with this example, https://www.mapbox.com/mapbox.js/example/v1.0.0/divicon/

The problem is I need to put a marker in the center of each country. Does anybody know a way to put a marker in the middle of each country?

I tried to use the natural earth admin 0 label points data but that has multiple points per country. It looked like the 'scalerank=0' points were the middle of the countries but if I filter on these points, I still get multiple points for some countries (russia has 4 for instance, but Belgium has 4 as well). If you plot all scalerank 0 points on a map you get the following result: https://a.tiles.mapbox.com/v4/persyval.jg5p7gm7/page.html?access_token=pk.eyJ1IjoicGVyc3l2YWwiLCJhIjoiX3lrSTNYYyJ9.6Ps4OlBCYmlkxQksKsGb7A#6/45.159/12.206

Does anybody know about a dataset that has one point per country or another way to put a marker in the center of each country with mapbox?

1

1 Answers

4
votes

It seems it's hard to find a list of country points for the placing of markers. So I took the mentioned admin labal 0 points and tried to sanitize it to have only one appropiate marker per country.

The result can be downloaded here in GEOJSON format: https://drive.google.com/file/d/0B6IQhfb-UYeUYk1mcUZaMmV0S1U/edit?usp=sharing

If you want to have a visual representation of the points take a look at this map: https://a.tiles.mapbox.com/v4/persyval.jgk4767c/page.html?access_token=pk.eyJ1IjoicGVyc3l2YWwiLCJhIjoiX3lrSTNYYyJ9.6Ps4OlBCYmlkxQksKsGb7A#4/36.49/34.32

I needed this points for a proof of concept project so I haven't checked all markers meticulously, I also haven't taken account some of the more political sensitive country borders. If you have a project in which this is of importance please check the file before using, but the points in this file can be easily edited to your own preferences.