eegeo.js

Adding an eeGeo polygon with holes (alternative syntax)

Add an eeGeo polygon to a map using an array in the constructor.

<!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.7900, -122.401],
      zoom: 15
    });

    var polygonPoints = [
      //Outer ring
      [[37.786617, -122.404654],
      [37.797843, -122.407057],
      [37.798962, -122.398260],
      [37.794299, -122.395234]],

      //A hole
      [[37.795168, -122.402665],
      [37.792300, -122.403781],
      [37.792656, -122.400420]],

      //Another hole
      [[37.790979, -122.403028],
      [37.790404, -122.401272],
      [37.788705, -122.402579],
      [37.789706, -122.403516]]];

    var poly = L.eeGeo.polygon(polygonPoints).addTo(map);
    </script>
  </div>
  </body>
</html>