wrld.js

Highlighting indoor map entities

Click on the 'Go to floor' button to navigate indoors and use the other buttons to toggle some entity highlights.

<!DOCTYPE HTML>
<html>
  <head>
    <script src="https://cdn-webgl.wrld3d.com/wrldjs/dist/latest/wrld.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" rel="stylesheet" />
    <style>
      #floorButtons {
        position: absolute;
        z-index: 20;
      }

      #floorButtons button {
        display: block;
        width: 100%;
      }
    </style>
  </head>
  
  <body>
  <div style="position: relative">
    <div id="floorButtons">
      <button onclick="toFloor()">Go to floor</button>
      <button onclick="setEntityHighlights()">Highlight entities</button>
      <button onclick="clearEntityHighlights()">Clear entities highlights</button>
    </div>
    <div id="map" style="height: 400px"></div>

    <script>
      var map = L.Wrld.map("map", "your_api_key_here", {
        center: [56.459801, -2.977928],
        zoom: 15,
        indoorsEnabled: true,
      });

      function setEntityHighlights() {
        map.indoors.setEntityHighlights(["0007","Small Meeting Room"], [255, 0, 0, 128]);
        map.indoors.setEntityHighlights(["0002","Meeting Room"], [0, 0, 255, 128]);
        map.indoors.setEntityHighlights("0033", [0, 255, 0, 128]);
      }

      function clearEntityHighlights() {
        map.indoors.clearEntityHighlights();
      }

      function toFloor() {
         map.indoors.enter("westport_house");
      }

      function onIndoorMapEntered() {
        map.indoors.setFloor(2);
        map.setView([56.459984, -2.978238], 20);
      }

      map.indoors.on("indoormapenter", onIndoorMapEntered);

    </script>

  </div>
  </body>
</html>
v0.1.1452