eegeo.js

Displaying the name of an indoor map

Show the name of an indoor map in a Leaflet popup. Click one of the blue markers to enter an indoor map. Close the popup bubble to exit the building.

<!DOCTYPE HTML>
<html>
  <head>
    <script src="https://cdn-webgl.eegeo.com/eegeojs/early_access/latest/eegeo.js"></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 = L.eeGeo.map("map", "your_api_key_here", {
        center: [37.7858, -122.401],
        zoom: 15,
        indoorsEnabled: true
      });
      
      function onIndoorMapEntered(event) {
        var latLng = map.getCenter();
        var buildingName = event.indoorMap.getIndoorMapName();

        var popup = L.popup().setLatLng(latLng).addTo(map);
        popup.setContent(buildingName);
        
        map.on("popupclose", function() { map.indoors.exit(); })
      }

      map.indoors.on("indoormapenter", onIndoorMapEntered);
    </script>
  </div>
  </body>
</html>