let state = 1
let map = new L.map('rendermaps', {
center: new L.LatLng(-2.0836809794977484, 113.63967449468988),
zoom: 5,
layers: [googleStreets]
});
let geo = L.geoJson({features:[]},{onEachFeature:function popUp(f,l){
let out = [];
if (f.properties){
for(let key in f.properties){
out.push(key+": "+f.properties[key]);
}
l.bindPopup(out.join("<br />"));
}
}});
let base = '../shp/testfile.zip';
if(state === 1) {
geo.addTo(map);
shp(base).then(function(data){
geo.addData(data);
});
} else {
map.removeLayer(geo);
}
i use removeLayer() and clearLayers() but no effect on map..
how to remove geojson when the state change to 0 ?
um this is probably more of an issue with leaflet, but if the state changes that code won't run, it only runs once, you may need to add a function that you can call that checks the state
i use
removeLayer()
andclearLayers()
but no effect on map..how to remove geojson when the state change to 0 ?