as title says I have problems removing maps before adding a new one, I have this function, which draws the tile given by a Spinner (parameter values are strings with correct leaflet tile names):
function drawMap(tile){
map.addLayer(tile);
map.eachLayer(function (layer) {
if (layer !== tile) {
map.removeLayer(layer);
}
});
}
Variable map is initialized this way, and it doesn't generate problems:
var map = L.map('map').fitBounds([
[myPosJSON.NEBoundLat, myPosJSON.NEBoundLng],
[myPosJSON.SWBoundLat, myPosJSON.SWBoundLng]
]);
How can I fix the drawMap() function to correctly display maps? (I also have to do it with a group of Overlays, but probably the procedure is the same for maps)