Placing objects on buildings

Query the altitude of a building in order to position a marker.

<!DOCTYPE HTML>
<html>
  <head>
    <script src="https://unpkg.com/wrld.js@1.x.x"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" rel="stylesheet" />
  </head>
  
  <body>
  <div style="position: relative">
    <div id="map" style="height: 400px"></div>
    <script>
        var map = Wrld.map("map", "your_api_key_here", {
            center: [37.795641, -122.404173],
            zoom: 18
        });

        var locations = [   [37.795159, -122.404336],
                            [37.795173, -122.404229]];

        function onInitialStreamingComplete() {
            addMarkerAboveBuilding(Wrld.latLng(locations[0]), "Point A");
            addMarkerAboveBuilding(Wrld.latLng(locations[1]), "Point B");
        }

        function addMarkerAboveBuilding(location, title) {
            var intersection = map.buildings.findBuildingAtLatLng(location);
            if (intersection.found) {
                Wrld.marker(location, {
                        elevation: intersection.point.alt,
                        title: title
                   }).addTo(map);
            }
        }

        map.on("initialstreamingcomplete", onInitialStreamingComplete);
    </script>
  </div>
  </body>
</html>
v1.1.0