mapbox / mapbox.js-plugins

Hosted plugins for Leaflet & Mapbox.js
mapbox.com/mapbox.js/plugins/
BSD 2-Clause "Simplified" License
13 stars 16 forks source link

Heatmap #9

Closed tmcw closed 10 years ago

tmcw commented 10 years ago

Is there a well-supported heatmap plugin? Might be good.

gundersen commented 10 years ago

the the idea of a heatmap pluging, this would be a sick demo ;)

tmcw commented 10 years ago

@mourner do you have any favorites here?

aaronlidman commented 10 years ago

The best I found: http://www.patrick-wied.at/static/heatmapjs/example-heatmap-leaflet.html

Actual plugin: http://www.patrick-wied.at/static/heatmapjs/src/heatmap-leaflet.js

tmcw commented 10 years ago

Cool, will see if he merges my pull req. If that happens, I'll update his site to newest leaflet and contribute some better docs, and then we should add it to the repo.

mourner commented 10 years ago

@tmcw yeah the Patrick's one is the best, but I wouldn't say it's well supported. There's also a supposedly high-performance WebGL one.

Actually I had some plans to write my own fast heatmap plugin a while ago, thought didn't get to it yet. The idea would be to cluster the points firts and then draw the heatmap, minimizing Canvas operations. I have a proof of concept for this.

bsudekum commented 10 years ago

Actually I had some plans to write my own fast heatmap plugin a while ago, thought didn't get to it yet. The idea would be to cluster the points firts and then draw the heatmap, minimizing Canvas operations. I have a proof of concept for this.

:thumbsup: I've been slightly dissatisfied with the offering. Right now, each plugin has fairly heavy tradeoffs in either performance, browser support, or ease of use.

tmcw commented 10 years ago

Hm, okay - unless someone has bandwidth to make this, I'm leaning towards fixing the warts around heatmap.js so that we can get the basics out there.

mourner commented 10 years ago

Right now, each plugin has fairly heavy tradeoffs in either performance, browser support, or ease of use.

@rsudekum if you could provide me with a test case for performance (e.g. a sample GeoJSON with tons of points that you would expect to work smoothly) that's not good enough in heatmap.js, I'd love to try to quickly make a proof of concept demo that's fast and smooth.

mourner commented 10 years ago

OK, after delving deeper into heatmap.js, I decided that its code is crap, so I cleaned up my past experiment on heatmaps and published on GH: https://github.com/mourner/simpleheat

It's super-simple and tiny (80 sloc vs 502 of heatmap.js) and has pretty much identical results while being about 6x faster.

I'll create a simple Leaflet layer from it (with proper zoom animations etc.) and publish as Leaflet.heatmap on Leaflet org.

mourner commented 10 years ago

Note that this is barebones heatmap code (without clustering for performance etc.). But it's much easier to experiment with a tiny and clean implementation now.

mourner commented 10 years ago

OK, here's the first version of my Leaflet heatmap plugin https://github.com/Leaflet/Leaflet.heat demo with 10k points: http://leaflet.github.io/Leaflet.heat/demo/

Feedback welcome! After it looks good, we should package it as a mapbox.js plugin and then I'll blog about it.

DennisOSRM commented 10 years ago

@mourner I have a real point data set that gives the walkability in San Francisico. Would you be interested in using that for you blog post?

mourner commented 10 years ago

@DennisOSRM I'd love to (if it looks good), please share.

mourner commented 10 years ago

Published as a mapbox.js plugin, deployed to CDN, added to plugins list and added an example: https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-heat/ — so this is done. Post to follow.

DennisOSRM commented 10 years ago

@mourner will send you the links later today

gundersen commented 10 years ago

love the demo of the heat map @mourner