Crater Lake National Park

NPMap

Digital maps for the National Park Service

GeoJSON Layer from GitHub

This example shows how you can easily add a GeoJSON layer served from GitHub to an NPMap web map. When you add a GeoJSON layer to an NPMap web map, you get basic display and identify support, along with integration with the route module, out of the box.

This example displays the Leonardtown, Maryland buildings: https://github.com/geobabbler/geodata/blob/master/geojson/leonardtown_bldgs.geojson.

 

Related resources:

Map

Code


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <div id="example-map" style="height:500px;position:absolute;width:500px;">
    </div>
    <script>
      var NPMap = NPMap || {};

      NPMap.config = {
        api: 'bing',
        center: {
          lat: 38.297909899190806,
          lng: -76.64208984375
        },
        div: 'example-map',
        layers: [{
          name: 'Leonardtown Buildings',
          type: 'GeoJson',
          url: 'https://raw.github.com/geobabbler/geodata/master/geojson/leonardtown_bldgs.geojson'
        }],
        zoom: 14
      };

      (function() {
        var s = document.createElement('script');
        s.src = 'http://www.nps.gov/npmap/1.0.0/bootstrap.js';
        document.body.appendChild(s);
      })();
    </script>
  </body>
</html>