Sometimes, we want to refresh leaflet map when map container is already initialized with JavaScript.
In this article, we’ll look at how to refresh leaflet map when map container is already initialized with JavaScript.
How to refresh leaflet map when map container is already initialized with JavaScript?
To refresh leaflet map when map container is already initialized with JavaScript, we call the off and remove methods before reloading the map.
For instance, we write
map.off();
map.remove();
to clear the map with off and remove before we reload the map to avoid the error.
Conclusion
To refresh leaflet map when map container is already initialized with JavaScript, we call the off and remove methods before reloading the map.