2017-04-10 2 views
1

Gibt es eine Möglichkeit, Informationen zum Gebäude (Geometrie, Höhe usw.) über die Mapbox-API abzurufen?Ermitteln von Gebäudeinformationen aus mapbox api

ich aus diesem Beispiel gestartet: https://www.mapbox.com/mapbox-gl-js/example/3d-buildings/ Es hat eine 3D-Ebene auf einer Karte erstellt. Alles, was ich brauche, ist, diese Informationen zu generieren, um 3D-Gebäude zu erstellen, um sie in meiner Anwendung zu verwenden. So

Ich habe versucht, diese API verwenden: https://www.mapbox.com/api-documentation/#retrieve-features-from-vector-tiles

Zum Beispiel, wenn ich das nennen:

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

ich verschiedene Angaben stammen bekommen, aber nichts für Gebäude.

zu Demnach: https://www.mapbox.com/blog/mapbox-studio-building-heights/

die Informationen sollte es irgendwo sein

Antwort

0

Ich habe die Lösung gefunden:

// 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) 
    }); 
});