Adding a heatmap

Add a heatmap to an outdoor map. Zoom in and out to view the heatmap at differing densities.

<!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">
    <div id="map" style="height: 400px"></div>
    <script>
      var map = Wrld.map("map", "your_api_key_here", {
        center: [51.501863, -0.089770],
        zoom: 13.5,
        environmentThemesManifest: "https://cdn-resources.wrld3d.com/mobile-themes-new/v1451/ambientdark/web.manifest.bin"
      });



      var optionalPolygonPoints = [
        [51.508604, -0.104459],
        [51.508443, -0.096146],
        [51.507262, -0.091732],
        [51.506585, -0.084959],
        [51.504438, -0.076184],
        [51.502556, -0.070538],
        [51.495054, -0.076442],
        [51.494416, -0.085674],
        [51.494161, -0.094522],
        [51.495264, -0.100525],
        [51.498727, -0.104775]
      ];

      var sw = Wrld.latLng(51.493606, -0.105091);
      var ne = Wrld.latLng(51.508994, -0.068091);
      var heatmapDataPoints = generateRandomData(1000, sw, ne);

      var wrldHeatmap = Wrld.heatmap(heatmapDataPoints, {
        polygonPoints: optionalPolygonPoints,
        densityStops: [
          {stop:0.0, radius:15.0, gain: 1.0},
          {stop:1.0, radius:45.0, gain: 0.2}
        ],
        // interpolate between our two density stops depending on camera zoom level
        interpolateDensityByZoom:true,
        zoomMin: 14,
        zoomMax: 17
      })
      .addTo(map);

      function generateRandomData(count, sw, ne) {
        var points = [];
        for (var i = 0; i < count; ++i) {
            var lat = Math.random() * (ne.lat - sw.lat) + sw.lat;
            var lng = Math.random() * (ne.lng - sw.lng) + sw.lng;
            points.push([lat, lng]);
        }

        return points;
      };
    </script>
  </div>
  </body>
</html>
v1.1.0