Geographic Information Systems Asked by Theodcyning on November 29, 2020
I have used an AJAX call to load a Black Sea GeoJSON that I want to display as a polygon on the map.
var blackSea = [];
var blackSeaData = new L.GeoJSON.AJAX("./blacksea.json");
blackSea.push(blackSeaData);
blackSea[0].addTo(map);
The first time I use blackSea[0].addTo(map)
it works, the polygon is displayed, and I can even change its style, but if I clear the map with clearMap()
and try it again it does not display. If I clearMap()
before the initial call it still displays, but after I clearMap()
again it does not.
What could be the problem here?
edit: the clearMap()
function:
function clearMap() {
for(i in map._layers) {
if(map._layers[i]._path != undefined) {
try {
map.removeLayer(map._layers[i]);
}
catch(e) {
console.log("problem with " + e + map._layers[i]);
}
}
}
}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP