Difference between revisions of "Test"

From A.P.E.S. wiki
Jump to navigation Jump to search
Line 17: Line 17:
 
      
 
      
 
     <script>
 
     <script>
      var url = 'usa.json';  // my GeoJSON data source, in same folder as my html page.
 
      var url2 = 'REFUGIA_MALEY96.geojson';  // my GeoJSON data source, in same folder as my html page.
 
 
 
       var map = L.map('map').setView([10, 5], 5);  
 
       var map = L.map('map').setView([10, 5], 5);  
  
Line 27: Line 24:
 
             attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
 
             attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
  
      // loading GeoJSON file - Here my html and usa_adm.geojson file resides in same folder
+
// load GeoJSON from an external file
      $.getJSON("usa.json", function(data) {
+
  fetch("REFUGIA_MALEY96.geojson").then(res => res.json()).then(data => {
        L.geoJson(data).addTo(newMap);
+
    // add GeoJSON layer to the map once the file is loaded
      });
+
    L.geoJson(data).addTo(map);
+
  });  
 
       // for Layer Control
 
       // for Layer Control
 
       var baseMaps = {
 
       var baseMaps = {

Revision as of 08:34, 25 February 2022