在地图框中查找街道地址

Find Street Address in Mapbox

本文关键字:街道 地址 查找 地图      更新时间:2023-09-26

我正在尝试使用地理编码器将街道地址解析为地理坐标。这似乎适用于世界各地的地区,但不适用于街道地址。以下示例仅转到位置(Bern),但似乎没有解析确切的地址(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);
    }
}

(原料药:https://www.mapbox.com/developers/api/geocoding/)

我错过了什么吗?还是我使用了错误的 API?

如果有人用谷歌搜索mapbox geocoding,这是第一个在"覆盖"标题下明确指出瑞士没有覆盖的命中。