Difference between revisions of "Test"

From A.P.E.S. wiki
Jump to navigation Jump to search
(Blanked the page)
Tag: Blanking
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
 
  <head>
 
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
 
    <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
 
    <style>
 
      #map {
 
      height: 500px;
 
      width: 100%;
 
      max-width: 100%;
 
      max-height: 100%;
 
      }
 
    </style>
 
  </head>
 
  <body>
 
    <div id="map" style="width: 100%; height: 500px;"></div>
 
  
    <script>
 
      // 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.
 
 
      var map = L.map('map').setView([10, 5], 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 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
 
      function style(feature) {
 
        return {
 
            fillColor: '#2214e2',
 
            fillOpacity: 0.5, 
 
            weight: 2,
 
            opacity: 1,
 
            color: '#2214e2',
 
            dashArray: '3'
 
        };
 
      }
 
      function forEachFeature(feature, layer) {
 
        var popupContent = "<p><b>ID: </b>"+ feature.properties.STATE_NAME +'</p>';
 
        layer.bindPopup(popupContent);
 
      }
 
 
      // Null variable that will hold layer
 
      var refugiaLayer = L.geoJson(null, {style: style});
 
      $.getJSON(refugia, function(data) {refugiaLayer.addData(data); });
 
      refugiaLayer.addTo(map);
 
 
      var aperangeLayer = L.geoJson(null, {onEachFeature: forEachFeature, style: style});
 
      $.getJSON(aperange, function(data) {aperangeLayer.addData(data); });
 
      aperangeLayer.addTo(map);
 
 
      // for Layer Control
 
      var baseMaps = {
 
        "Open Street Map": osm, 
 
        "Open Topo Map": topo, 
 
      };
 
 
      var overlayMaps = {
 
        "Refugia":refugiaLayer
 
        "Ape range":aperangeLayer
 
      };
 
 
      //Add layer control
 
      L.control.layers(baseMaps, overlayMaps).addTo(map);
 
 
    </script>
 
  </body>
 
</html>
 

Latest revision as of 05:51, 29 September 2022