eegeo.js

Custom indoor map entrance markers

Make your own indoor map entrance markers with custom behavior. Click the markers in this example to enter or exit an indoor map.

<!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,
        displayEntranceMarkers: false
      });

      function addCustomEntranceMarker(event) {
        var entrance = event.entrance;
        var marker = L.marker(entrance.getLatLng()).addTo(map);
        
        marker.on("click", function() {
          if (map.indoors.isIndoors()) {
            map.indoors.exit();
          }
          else {
            map.indoors.enter(entrance);
          }
        });
      }
      
      map.indoors.on("indoorentranceadd", addCustomEntranceMarker);
    </script>
  </div>
  </body>
</html>