Leaflet / Leaflet.heat

A tiny, simple and fast heatmap plugin for Leaflet.
http://leaflet.github.io/Leaflet.heat/demo
BSD 2-Clause "Simplified" License
1.55k stars 525 forks source link

Is it possible to change the intensity color based on the number of heatpoints combined in view? #107

Closed jericopulvera closed 5 years ago

jericopulvera commented 5 years ago

I want to achieve this coloring.

1-1000 yellow 1001-2000 orange 2001-3000 red 3001-4000 maroon 4001-5000 mahogany

Sti2nd commented 5 years ago

I don't think it is a built in feature. A workaround could possibly be: If each of these points have an intensity of 0.0001 you could input these five colours and set max point intensity to 0.5.

NB: I have not read the actual source code. This assumes the colours in the heatmap is simply calculated from the sum of point intensities in the grids it creates. Meaning, If there are 5000 points in one square of the grid, that square should get intensity 5000 * 0.0001 = 0.5, which will be mahogany. We also have to assume the range is divided equally between the five colours. If you check the source code you can find out if the assumptions are true.

jericopulvera commented 5 years ago

@Sti2nd thanks. I'll try this.

jericopulvera commented 5 years ago

Doesn't work. All I get is mahogany and I have 296 heats. It should return yellow.

Sti2nd commented 5 years ago

Well, it does depend on your zoom level or how large the clusters in the grid are in the source code.

You only have 296 points on your map? And all points have intensity 0.0001?

jericopulvera commented 5 years ago

@Sti2nd yeah. But I am not getting yellow. I tried it in all zoom value. all mahogany

Sti2nd commented 5 years ago

Oh well, I guess my assumptions were wrong or it might be a bug somewhere.

I see there are quite a few issues about heat colour, and a some pull requests as well... https://github.com/Leaflet/Leaflet.heat/pull/78

Since this repo is not actively maintained anymore, your best shot is perhaps to modify the source by e.g. basing it off the already existing pull requests.