Difference between revisions of "Test"
Jump to navigation
Jump to search
Line 17: | Line 17: | ||
<script> | <script> | ||
− | |||
var map = L.map('map').setView([10, 5], 4); | var map = L.map('map').setView([10, 5], 4); | ||
Line 26: | Line 25: | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map); | attribution: '© <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: | ||
}; | }; | ||
} | } | ||
− | + | function forEachFeature(feature, layer) { | |
− | + | var popupContent = "<p><b>ID: </b>"+ feature.properties.STATE_NAME +'</p>'; | |
− | + | layer.bindPopup(popupContent); | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// Null variable that will hold layer | // Null variable that will hold layer | ||
− | var | + | var refugiaLayer = L.geoJson(null, {onEachFeature: forEachFeature, style: style}); |
− | + | $.getJSON(refugia, function(data) {refugiaLayer.addData(data); }); | |
− | $.getJSON( | + | 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 | // for Layer Control | ||
Line 72: | Line 63: | ||
var overlayMaps = { | var overlayMaps = { | ||
− | "Refugia": | + | "Refugia":refugiaLayer |
+ | "Ape range":aperangeLayer | ||
}; | }; | ||
Revision as of 10:49, 25 February 2022