0

I am working on a web app to display geospatial data on a google map. I am using google maps java script api v3. How can i load a geojson file on my local machine on the map?

<!DOCTYPE html>
<html>
  <head>
    <title>Data Layer: Simple</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
    <script>
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://storage.googleapis.com/maps-devrel/google.json');


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

    </script>


  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>

using this code i can load a geojson file on the same domian. I want to do this for a geojson file in my local machine

DTNPerera
  • 95
  • 1
  • 12
  • This should help you http://stackoverflow.com/questions/7346563/loading-local-json-file – Verma Jun 30 '15 at 17:30
  • https://developers.google.com/maps/documentation/javascript/examples/layer-data-dragndrop I found that this can eaisily solve my problem – DTNPerera Jul 01 '15 at 06:51

0 Answers0