eegeo.js

Picking points on the map

Place a marker on the ground by double-clicking on the 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 id="content" 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 mouseDownPoint = null;

      function onMouseDown(event) {
        mouseDownPoint = event.layerPoint;
      }

      function onMouseUp(event) {
        var mouseUpPoint = event.layerPoint;
        var mouseMoved = mouseUpPoint.distanceTo(mouseDownPoint) > 5;

        if (!mouseMoved) {
          var latlng = event.latlng;
          var marker = L.marker(latlng).addTo(map);
        }
      }

      map.on("mousedown", onMouseDown);
      map.on("mouseup", onMouseUp);
    </script>
  </div>
  </body>
</html>