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 = 'files/REFUGIA_MALEY96.json';  // my GeoJSON data source, in same folder as my html page.
 
  
 
       var map = L.map('map').setView([10, 5], 4);  
 
       var map = L.map('map').setView([10, 5], 4);  
Line 26: Line 25:
 
             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);
 
          
 
          
 +
 +
      // GEOJSON FILES
 +
      var refugia = 'files/REFUGIA_MALEY96.json';  // my GeoJSON data source, in same folder as my html page.
 +
      var aperange = 'files/species_15933.geojson';  // my GeoJSON data source, in same folder as my html page.
 +
  
 
       // Set style function that sets fill color property
 
       // Set style function that sets fill color property
Line 38: Line 42:
 
         };
 
         };
 
       }
 
       }
       // var highlight = {
+
       function forEachFeature(feature, layer) {
        // 'fillColor': 'yellow',
+
        var popupContent = "<p><b>ID: </b>"+ feature.properties.STATE_NAME +'</p>';
        // 'weight': 2,
+
        layer.bindPopup(popupContent);
        // 'opacity': 1
+
      }
      // };
 
 
 
        function forEachFeature(feature, layer) {
 
 
 
                var popupContent = "<p><b>ID: </b>"+ feature.properties.STATE_NAME +'</p>';
 
 
 
                layer.bindPopup(popupContent);
 
 
 
                // layer.on("click", function (e) {
 
                    // stateLayer.setStyle(style); //resets layer colors
 
                    // layer.setStyle(highlight);  //highlights selected.
 
                // });
 
        }
 
  
 
       // Null variable that will hold layer
 
       // Null variable that will hold layer
       var stateLayer = L.geoJson(null, {onEachFeature: forEachFeature, style: style});
+
       var refugiaLayer = L.geoJson(null, {onEachFeature: forEachFeature, style: style});
 
+
       $.getJSON(refugia, function(data) {refugiaLayer.addData(data); });
       $.getJSON(url, function(data) {
+
      refugiaLayer.addTo(map);
            stateLayer.addData(data);
 
        });
 
  
       stateLayer.addTo(map);
+
       var aperangeLayer = L.geoJson(null, {onEachFeature: forEachFeature, style: style});
 +
      $.getJSON(aperange, function(data) {aperangeLayer.addData(data); });
 +
      aperangeLayer.addTo(map);
  
 
       // for Layer Control
 
       // for Layer Control
Line 72: Line 63:
  
 
       var overlayMaps = {
 
       var overlayMaps = {
         "Refugia":stateLayer
+
         "Refugia":refugiaLayer
 +
        "Ape range":aperangeLayer
 
       };
 
       };
  

Revision as of 10:49, 25 February 2022