Reputation: 27214
I'm trying to resolve street addresses to geographic coordinates using the geocoder. That seems to work fine for places around the world, but not so much for street addresses. The following example only goes to the place (Bern
) but doesn't seem to resolve the exact address (Kramgasse 42
):
var geocoder = L.mapbox.geocoder('mapbox.places'),
map = L.mapbox.map('map', 'examples.map-h67hf2ic');
geocoder.query('Kramgasse 42, Bern, Switzerland', showMap);
function showMap(err, data) {
// The geocoder can return an area, like a city, or a
// point, like an address. Here we handle both cases,
// by fitting the map bounds to an area or zooming to a point.
if (data.lbounds) {
map.fitBounds(data.lbounds);
} else if (data.latlng) {
map.setView([data.latlng[0], data.latlng[1]], 13);
}
}
(API: https://www.mapbox.com/developers/api/geocoding/)
Am I missing something? Or am I using the wrong api?
Upvotes: 0
Views: 1441