从 mapbox 获取建筑信息 api

Getting building information from mapbox api

有没有办法从地图框获取建筑信息(几何形状、高度等)API?

我从这个例子开始: https://www.mapbox.com/mapbox-gl-js/example/3d-buildings/ 它在地图视图上添加了一个 3D 图层。我只需要获取用于生成 3D 建筑的信息,以便在我的应用程序中使用。

所以我尝试使用这个 API: https://www.mapbox.com/api-documentation/#retrieve-features-from-vector-tiles

例如,如果我这样调用:

https://api.mapbox.com/v4/mapbox.mapbox-streets-v7/tilequery/-74.0066,40.7135.json?radius=50&limit=50&access_token=

我得到了各种信息,但与建筑物无关。

据此: https://www.mapbox.com/blog/mapbox-studio-building-heights/

信息应该在某处

我找到了解决方案:

// Dafault public token, replace with yours if you have one
mapboxgl.accessToken = 'pk.eyJ1IjoibHZpZ2dpYW5pIiwiYSI6ImNpeHZvbGVqMzAwMGoyd3J5YXllbnpuOHQifQ.RAyB0ZTsnLggAZYp_TPmHQ';

var map = new mapboxgl.Map({
    container: div,
    style: 'mapbox://styles/mapbox/outdoors-v9',
    interactive: false
});

map.fitBounds(
    someBounds, // arbitrary bounds 
    {
        linear: true
    });

map.on("load", function(){
    features = map.queryRenderedFeatures(
            { layers: ["building"], filter: ['==', 'extrude', 'true']}); // This is where I get building information

    features.forEach(function(feature){
        console.log(feature.geometry);  // feature.geometry getter returns building shape points (basement)
        console.log(feature.properties.height); // this is the building height
        console.log(feature.properties.min_height); // this is the building part elevation from groung (e.g. a bridge)
    });
});