-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To remove or clear all active layers without passing specific layer. #3238
Comments
There is more than sufficient functionality for removing layers from the map or removing from / clearing other grouped layers.
http://leafletjs.com/reference.html#map-eachlayer If you need that functionality a lot, you can include it into
The reason (i'm speculating here) this isn't included in http://leafletjs.com/reference.html#layergroup-clearlayers All the functionality you need is already there, you just need to implement it correctly. If you're having problems or need help with your implementation then posting to this issuetracker isn't the right thing to do. You'll get feedback and help much sooner if you use the proper channels for that like in the Leaflet's Google group or posting a question on Stackoverflow with the leaflet tag. |
^^ 👍 |
here once when i m doing its saying like map is not defined. Actually i have a mapContainer in the render section below.
Also if i give this
then it shows already mapContainer exists error. So i dont know how to do? |
Please aks for help on StackOverflow, this is a old Issue where nobody is looking into it. |
I did not find any way to clear or remove all active layers. I think there should be a function to remove all active layers without passing the specific layer. what do you think?
I found 2 major functions for this purpose.
map.removeLayer(Markers);
Markers.clearLayers();
But I am having a problem while using this function... actually, it works just once which means remove only one layer of markers or maybe i am doing something wrong.
var map = new L.Map('map');
function getMarker(){
var heatMap = "";
if(Markers) {
map.removeLayer(Membersx);
map.removeLayer(map._layers);
}
$.ajax({
type: "post",
url: "app_lib->FOLDER['admin'].$this->router->class ?>/buscador",
dataType: "json",
data: {layers:}
success: function(result){
$.each(result, function(index, layer) {
var Markers = L.geoJson(layer.data ,{
pointToLayer: function(feature, latlng) {
if(feature.geometry.type == 'Point'){
return L.marker(latlng, {icon: L.ExtraMarkers.icon({ icon: feature.marker_icon, markerColor: feature.marker_color, shape: feature.marker_type, prefix: 'fa' }) })
}
},
onEachFeature: onEachFeature
});
map.addLayer(Markers);
});
}
May you please help me on this issue...?
Thanks in advance.
The text was updated successfully, but these errors were encountered: