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://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">
    <button style="position: absolute; z-index: 20" onclick="exitIndoors()">Exit Indoor Map</button>
    <div id="map" style="height: 400px"></div>

    <script>
      var map = Wrld.map("map", "your_api_key_here", {
        center: [37.7858, -122.401],
        zoom: 15,
        indoorsEnabled: true,
        displayEntranceMarkers: false
      });

      function exitIndoors() {
        map.indoors.exit();
      }

      function addCustomEntranceMarker(event) {
        var entrance = event.entrance;
        var marker = Wrld.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>
v1.1.0