wrld.js

Precaching map data

Precache map data for future use.

<!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" />
  </head>
  
  <body>
  <div style="position: relative">
    <div id="map" style="height: 400px"></div>
    <script>
      var map = L.Wrld.map("map", "your_api_key_here", {
        center: [37.7952, -122.4028],
        zoom: 16
      });

      var precacheCompleteCallback = function(precacheResult) {
        if (precacheResult.getSucceeded()) {
          alert("Precaching complete");
        } else {
          alert("Precaching failed");
        }
      }
      <!-- Precache a 2000 meter radius around this point -->
      map.precacheWithDetailedResult([37.7952, -122.4028], 2000, precacheCompleteCallback);
    </script>

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