{"action":"opened","issue":{"url":"https://api.github.com/repos/Esri/esri-leaflet/issues/528","labels_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/528/labels{/name}","comments_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/528/comments","events_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/528/events","html_url":"https://github.com/Esri/esri-leaflet/issues/528","id":75070924,"number":528,"title":"map.removeLayer() not removing layers from the map","user":{"login":"developingcountries","id":5304587,"avatar_url":"https://avatars.githubusercontent.com/u/5304587?v=3","gravatar_id":"","url":"https://api.github.com/users/developingcountries","html_url":"https://github.com/developingcountries","followers_url":"https://api.github.com/users/developingcountries/followers","following_url":"https://api.github.com/users/developingcountries/following{/other_user}","gists_url":"https://api.github.com/users/developingcountries/gists{/gist_id}","starred_url":"https://api.github.com/users/developingcountries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/developingcountries/subscriptions","organizations_url":"https://api.github.com/users/developingcountries/orgs","repos_url":"https://api.github.com/users/developingcountries/repos","events_url":"https://api.github.com/users/developingcountries/events{/privacy}","received_events_url":"https://api.github.com/users/developingcountries/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-11T03:27:24Z","updated_at":"2015-05-11T03:27:24Z","closed_at":null,"body":"Hello,\r\n\r\nI am wondering what is an effective way to remove map layers from a map? Currently, I have a menu system that will add layers to show on a map using the addTo(map) function. I want to have a \"Clear all layers\" button to clear all the map layers.  \r\n\r\nMy code is at  http://codepen.io/anon/pen/OVMQNX, see especially the function clearAllLayers() where I'm using the map.removeLayer() function.  The problem is that when I iterate through a collection of L.esri.featureLayer ('serviceLayer Address') to call map.removeLayer() to remove layers from the map, the layers are not clearing. They still remain on the map even though I call map.removeLayer() function.  I tried this in different browsers (Chrome, IE, etc.) and it's still the same problem. Can you advise an effective way to do this?  \r\n\r\nI want to be able to click on \"Clear All Map Layers\" to clear all the layers and then continue to resume and add any service layer and as many layers to the map as I want (e.g. a service layer would be something like  http://services1.arcgis.com/PcevIObMOTNlnhqj/arcgis/rest/services/GAC_North_Bay/FeatureServer/0) \r\nI looked through the Esri leaflet documentation but there isn't any info posted about how to do this. \r\n\r\nThanks.\r\n\r\n\r\nPeter"}}