Skip to content
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

How to refresh layer with Leaflet/OSM #17

Open
mikekay01 opened this issue Mar 5, 2013 · 5 comments
Open

How to refresh layer with Leaflet/OSM #17

mikekay01 opened this issue Mar 5, 2013 · 5 comments

Comments

@mikekay01
Copy link

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) {
console.log('data');
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?

@bozdoz
Copy link
Contributor

bozdoz commented Mar 5, 2013

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
heatmap.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
heatmap.redraw();

@mikekay01
Copy link
Author

I'm testing right now...

@bozdoz
Copy link
Contributor

bozdoz commented Mar 6, 2013

How'd that go? :)

@mikekay01
Copy link
Author

It seems to work .

Sent from my iPhone

On Mar 5, 2013, at 6:03 PM, Benjamin J DeLong notifications@github.com wrote:

How'd that go? :)


Reply to this email directly or view it on GitHub.

@mikekay01
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants