使用 MapBox 键的 OSMBuilding

OSMBuilding with MapBox key

看这里的例子:https://osmbuildings.org/examples/

在 JS 部分中,他们定义了点击事件:

 osmb.click(function(e) {
  var url = 'https://data.osmbuildings.org/0.2/uejws863/feature/'+ e.feature +'.json';
  ajax(url, function(json) {
    var content = '<b>OSM ID '+ e.feature +'</b>';
    for (var i = 0; i < json.features.length; i++) {
      content += '<br><em>OSM Part ID</em> '+ json.features[i].id;
      content += '<br>'+ formatJSON(json.features[i].properties.tags);
    }

    L.popup({ maxHeight:200, autoPanPaddingTopLeft:[50,50] })
      .setLatLng(L.latLng(e.lat, e.lon))
      .setContent(content)
      .openOn(map);
  });
});

在此代码中,uejws863 为 "YOUR_MAPBOX_KEY"。我可以找到我的 MAPBOX 访问令牌,但如果我用我的令牌更改 uej..,它仍然显示 "unauthorized"。 基本上我正在尝试 运行 在本地主机上的这个例子。 接下来我该怎么做才能找到钥匙或更改 api 调用?

查看 OSM 建筑 examples 在向 MapBox 服务器发出图块请求时使用 "YOUR_MAPBOX_KEY",例如:

map.addMapTiles('https://{s}.tiles.mapbox.com/v3/[YOUR_MAPBOX_KEY]/{z}/{x}/{y}.png');

向 OSM Buildings 服务器发出请求时,他们使用 anonymous 作为密钥:

map.addGeoJSONTiles('https://{s}.data.osmbuildings.org/0.2/anonymous/tile/{z}/{x}/{y}.json');

尽管我使用 anonymous 键得到结果,例如:

https://data.osmbuildings.org/0.2/anonymous/style.json

我建议您注册以从 OSM Buildings 获取密钥,而不是从 MapBox

https://osmbuildings.org/login/