Google Maps - GeoJSON sample

by tadchristiansen

HTML

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"></script>
<div id="map-canvas"></div>

CSS

html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }

JavaScript

var map;
function initialize() {
  // Create a simple map.
  map = new google.maps.Map(document.getElementById('map-canvas'), {
    zoom: 4,
    center: {lat: -28, lng: 137.883}
  });

  // Load a GeoJSON from the same server as our demo.
  map.data.loadGeoJson('https://api.nearmap.com/coverage/v2/aggregate/boundaries.geojson?types=3D&apikey=ZWZjNWM2OWQtNzBmMi00MTEzLWJmNmEtNDI5MWY2MGRmMTFk');
    
    
// Set the stroke width, and fill color for each polygon
  var featureStyle = {
    fillColor: 'green',
    strokeWeight: 1
  }
  map.data.setStyle(featureStyle);    
}

google.maps.event.addDomListener(window, 'load', initialize);