Difference between revisions of "African great ape layers"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | + | [[Spatial Layers]] > [[African great ape layers]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <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 gadendist2021 = 'files/african_great_apes/great_ape_dendist_ION2021.geojson'; | ||
+ | var gaabundance = 'files/african_great_apes/afr_great_ape_ab.geojson'; | ||
+ | |||
+ | // Create map | ||
+ | var map = L.map('map').setView([-0, 6], 4); | ||
− | + | // Create open maps | |
− | + | var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',{attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map); | |
− | + | var topo=new L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',{attribution: '© <a href="http://osm.org/copyright">OpenTopoMap</a> contributors'}).addTo(map); | |
+ | |||
+ | // POPUP -> this "feature.properties.xxxx" needs to be matching the file please look it up in the file | ||
+ | //function forEachFeature(feature, layer) { var popupContent = "<p><b>Species: </b>"+ feature.properties.Subspecies +'</p>'; layer.bindPopup(popupContent);} | ||
− | + | // Set style function that sets fill color property | |
− | + | function stylegaabundance(feature) { return { fillColor: '#5F0CE4', fillOpacity: 0.7, weight: 2, opacity: 0.7, color: '#5F0CE4', dashArray: '3' }; } | |
+ | |||
+ | // Null variable that will hold layer // took out onEachFeature: forEachFeature, | ||
+ | var gaabundanceLayer = L.geoJson(null, {style: stylegaabundance}); | ||
+ | |||
+ | $.getJSON(gaabundance); gaabundanceLayer.addTo(map); | ||
− | + | // for Layer Control | |
+ | var baseMaps = { | ||
+ | "Open Street Map": osm, | ||
+ | "Open Topo Map": topo, | ||
+ | }; | ||
+ | // not showing ga densdist 2021 here because it takes ages to load... | ||
+ | var overlayMaps = { | ||
+ | "Great ape abundance per site": gaabundanceLayer, | ||
+ | }; | ||
+ | |||
+ | //Add layer control | ||
+ | L.control.layers(baseMaps, overlayMaps).addTo(map); | ||
− | </body> | + | </script> |
+ | </body> | ||
</html> | </html> |