I'm using mapbox (https://www.mapbox.com/mapbox.js/api/v2.0.1/) and wounder if there is a way to get the country (or city?) of a [lat, lng] pair.
Would be nice if somebody could help me out :)
Kind regards
I'm using mapbox (https://www.mapbox.com/mapbox.js/api/v2.0.1/) and wounder if there is a way to get the country (or city?) of a [lat, lng] pair.
Would be nice if somebody could help me out :)
Kind regards
Here is a package for that: https://github.com/vkurchatkin/which-country
You can install it via npm and use in browser with browserify. The API is quite simple:
var wc = require('which-country');
console.log(wc([-100, 40])); // prints "USA"
https://www.mapbox.com/developers/api/geocoding/
I found this endpoint a bit back when I had to do something similar: http://api.tiles.mapbox.com/v4/geocode/mapbox.places-country-v1/-73.989,40.733.json?access_token=pk.eyJ1IjoibWFyaXNhZmx5bm4iLCJhIjoibG9JcmhrbyJ9.yDc_eDeDW2DeM_JVSQPp7g
Ok I have now fixed that task with http://www.mapquestapi.com/geocoding/#reverse Works pretty good for me.