Skip to content
Advertisement

Remove previous markers before update marker in leaflet map?

Here I am trying to update the markers on map upon successful ajax request but I am being unable to remove previously added markers before adding new one. How can I do it here ?

JavaScript

Advertisement

Answer

Here’s an example, that stores the Marker inside each location Object of your locations Array.

Additionally, create two functions, drawLocationsToMap and removeLocationsFromMap.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement