Difference between revisions of "Test"

From A.P.E.S. wiki
Jump to navigation Jump to search
Line 18: Line 18:
  
 
     <script>
 
     <script>
    // GEOJSON FILES  
+
      // GEOJSON FILES  
    var url = 'files/REFUGIA_MALEY96.json';  // my GeoJSON data source, in same folder as my html page.
+
      var url = 'files/REFUGIA_MALEY96.json';  // my GeoJSON data source, in same folder as my html page.
    var url2 = 'files/species_15933.geojson';  // my GeoJSON data source, in same folder as my html page.
+
      var url2 = 'files/species_15933.geojson';  // my GeoJSON data source, in same folder as my html page.
  
    var map = L.map('map').setView([10, 7], 5);  
+
      var map = L.map('map').setView([10, 6], 4);  
  
    var topo=new L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',{attribution: '&copy; <a href="http://osm.org/copyright">OpenTopoMap</a> contributors'}).addTo(map);
+
      var topo=new L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',{attribution: '&copy; <a href="http://osm.org/copyright">OpenTopoMap</a> contributors'}).addTo(map);
    var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',{attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
+
      var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',{attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
  
  
    // Set style function that sets fill color property
+
      // Set style function that sets fill color property
    function style(feature) {
+
      function style(feature) {
      return {
+
        return {
        fillColor: 'green',  
+
          fillColor: 'green',  
        fillOpacity: 0.5,   
+
          fillOpacity: 0.5,   
        weight: 2,
+
          weight: 2,
        opacity: 1,
+
          opacity: 1,
        color: '#ffffff',
+
          color: '#ffffff',
        dashArray: '3'
+
          dashArray: '3'
      };
+
        };
    }
+
      }
    function style2(feature) {
+
      function style2(feature) {
      return {
+
        return {
        fillColor: 'blue',  
+
          fillColor: 'blue',  
        fillOpacity: 0.5,   
+
          fillOpacity: 0.5,   
        weight: 2,
+
          weight: 2,
        opacity: 1,
+
          opacity: 1,
        color: '#ffffff',
+
          color: '#ffffff',
        dashArray: '3'
+
          dashArray: '3'
      };
+
        };
    }
+
      }
  
    // Null variable that will hold layer
+
      // Null variable that will hold layer
    var stateLayer = L.geoJson(null, {style: style});
+
      var stateLayer = L.geoJson(null, {style: style});
    var stateLayer2 = L.geoJson(null, {style: style2});
+
      var stateLayer2 = L.geoJson(null, {style: style2});
  
    $.getJSON(url, function(data) {
+
      $.getJSON(url, function(data) { stateLayer.addData(data);});
    stateLayer.addData(data);
+
      stateLayer.addTo(map);
    });
 
  
    stateLayer.addTo(map);
+
      $.getJSON(url2, function(data) { stateLayer2.addData(data); });
 +
      stateLayer2.addTo(map);
  
    $.getJSON(url2, function(data) {
+
      // for Layer Control
    stateLayer2.addData(data);
+
      var baseMaps = {
    });
+
      "Open Street Map": osm, 
 
+
      "Open Topo Map": topo, 
    stateLayer2.addTo(map);
+
      };
 
 
    // for Layer Control
 
    var baseMaps = {
 
    "Open Street Map": osm, 
 
    "Open Topo Map": topo, 
 
    };
 
  
    var overlayMaps = {
+
      var overlayMaps = {
    "Refugia":stateLayer,
+
      "Refugia":stateLayer,
    "Ape range":stateLayer2,
+
      "Ape range":stateLayer2,
    };
+
      };
  
    //Add layer control
+
      //Add layer control
    L.control.layers(baseMaps, overlayMaps).addTo(map);
+
      L.control.layers(baseMaps, overlayMaps).addTo(map);
  
 
     </script>  
 
     </script>  
 
   </body>
 
   </body>
 
</html>
 
</html>

Revision as of 11:14, 25 February 2022