Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


How to refresh layer with Leaflet/OSM #17

mikekay01 opened this Issue · 5 comments

2 participants


How do I refresh my heatmap with new data in a Leaflet/OSM environment?

I can successfully build the map using:
heatmap = new L.TileLayer.HeatCanvas...

and can load the map using:
for (var i in MapData) {
heatmap.pushData(MapData[i][0], MapData[i][1], MapData[i][2])

My problem is I do not know how to clear the heatmap and load new data.

I have tried using heatmap.clear(), but this seems to have no effect as everytime I push data into the heatmap it simply adds to the existing data.

Does anyone know how to basically clear the data from a heatmap, load new data in, and redraw the map?


I just sent a pull request to remove the data when using heatmap.clear().

What you need to do for now, I believe, is:

//clear the data = [];
//add the data
for (var i in MapData) {
heatmap.pushData(MapData[i][0], MapData[i][1], MapData[i][2])
//redraw already clears the heatmap


I'm testing right now...


How'd that go? :)


Sorry, I just got back to this portion of my project. Unfortunately, it doesn't work. The map continues to add new data points. Is there a fix for this situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.