Reputation: 97
I'm trying to create an android & ios application where you are able to see the whole world. I only need the countries displayed in an individual colour. No needs for cities, street, etc. It should look something like this:
I cant use a static image, it needs to be colorised individually for every user.
So far i've tried using Mapbox. But with Mapbox i haven't found dynamic styles. It seems like they have to be created in advanced with Mapbox Studio. And i tried Google Maps with tile layers. But for that (as i understand) i would need to recreate the whole world. That would be a huge effort.
So none of them really fits my needs. Maybe i'am missing an easy trick but i'm getting really frustrated with that.
Any help is highly appreciated!
Upvotes: 5
Views: 2120
Reputation: 3064
In order to do this you will have to do a few things. First you need to get data from the IMF about each country's HDI score. Luckily, you can get this data from the United Nations Development Programme Human Development API: http://ec2-54-174-131-205.compute-1.amazonaws.com/API/HDRO_API.php/indicator_id=137506/year=2017
Next, you'll have to figure out what HDI denotes developed, developing, less developed, and least developed. The United Nations Development Programme categorizes HDI into four (five including nations with unavailable data) categories:
Now you need to look at this data and create a map in MapBox Studio. You could either go through the JSON of data and create a new style for each nation (tutorial here: https://docs.mapbox.com/help/tutorials/style-single-country/) or you could parse the JSON file on the front end and add the styles from the application.
If you create a MapBox map, the map's style can be used on your application by setting the map's style property. This is done by, after creating the map, taking the share URL and setting your map's style to this URL when it is initialized on the front end.
Using the share URL, you can create a map on the front end.
iOS (Swift):
var mapView = MGLMapView()
mapView.styleURL = URL(string: "mapbox://styles/davidchopin/cjtz90km70tkk1fo6oxifkd67")
iOS (Objective-C):
// Replace the string in the URL below with your custom style URL from Mapbox
//Studio.
// Read more about style URLs here: https://www.mapbox.com/help/define-style-url/
NSURL *styleURL = [NSURL URLWithString:@"mapbox://styles/davidchopin/cjtz90km70tkk1fo6oxifkd67"];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
styleURL:styleURL];
Android (Java):
mapboxMap.setStyle(new Style.Builder().fromUrl("mapbox://styles/davidchopin/cjtz90km70tkk1fo6oxifkd67"), new
Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
// Custom map style has been loaded and map is now ready
}
});
Android (Kotlin):
mapboxMap.setStyle(Style.Builder().fromUrl("mapbox://styles/davidchopin/cjtz90km70tkk1fo6oxifkd67")) {
// Custom map style has been loaded and map is now ready
}
Upvotes: 3