eegeo.js

Querying camera location and zoom

Query and display the current location and zoom of the camera.

<!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: 16
      });

      var popup = L.eeGeo.popup({closeOnClick: false}).setLatLng(map.getCenter());
      popup.addTo(map);

      function updatePopup() {
        var zoom = map.getZoom();
        var center = map.getCenter();
        var lat = center.lat.toFixed(3);
        var lng = center.lng.toFixed(3);
        popup.setLatLng(center);
        popup.setContent("LatLng: " + lat + ", " + lng + "<br/>" + "Zoom: " + zoom);
      }

      // The update event is fired every frame
      map.on("update", updatePopup);
    </script>
  </div>
  </body>
</html>