Leaflet.heat
Leaflet.heat copied to clipboard
Does the intensity/altitude value work with individual points?
It seems that the only way to have sections show up as higher color intensities is to have several points clustered close together.
In other words, when given individual points (that are far apart from another) with different altitude values, the heatmap will show the same color of intensity for all points. Is this expected behavior?
@eddielu No, the plugin should work with an array of individual points where the altitude values represent the intensity at that point (as explained in the docs).
I am having the same issue with the most recent version of leaflet.heat, which seems buggy. The following test code...
var heatData = [
[
-85.4667,
-142.4,
1
],
[
-38.0364,
141.9025,
278
],
[
-39.05835,
174.82185,
1596
],
...
];
var heatmap = L.heatLayer(heatData, {
minOpacity: 0.1,
max: _.maxBy(heatData, function(latLngDensity) { return latLngDensity[2]; })[2],
radius: 70,
blur: 30,
gradient: {
0.4: '#f23e45',
0.50: 'lime',
0.70: 'yellow',
0.95: '#FF8300',
1.0: 'red'
}
}).addTo(map);
produces the following:
However, when I run the exact same code with an older version of leaflet.heat (which I pulled out of a legacy project I'm taking over--the version number wasn't recorded), it produces something that looks like what I expect:
If in the first example with the current version I manually set max to 15 (rather than the actual max altitude of ~61,000), it starts to look like what is produced in the second example.
Leads me to think there's something buggy with the most recent version. Will compare the two versions I'm working with to see if I can pinpoint the issue. If anyone has any suggestions, please post.
I'm running these tests in Chrome 47.0.2526.106 (64-bit).
@jameslaneconkling looks like a perfect case for using git bisect
! I'll be happy to know what the issue is too.
I'm having the same problem with the most recent version, can anyone tell me how to get an older version without that bug? Thanks.
same issue here
+1, my problem is probably related to this one.
Namely, changing the background map (as I have several maps with different resolutions) will completely change the heatmap even when the data stays the same. This is probably due to point intensity being related to the zoom level, instead of staying the same?
I have committed a pull request which resolves this issue:
https://github.com/Leaflet/Leaflet.heat/pull/60
@jameslaneconkling If you have the older version of this library, can you please share?
I wonder if this is the culprit: https://github.com/Leaflet/Leaflet.heat/blob/gh-pages/src/HeatLayer.js#L170
... instead of just accumulating the k
value, seems like it should be doing a cumulative moving average: cell[2] = cell[2] + (k - cell[2]) / (n + 1)
- similar to the way the x/y coordinates are spatially averaged with alt
weighting. Would need to keep a running n++
that tracks the number of points being considered within a cell, or offer a specifiable behavior here; does the user want to sample the mean/median/max cell value? I could imagine wanting different things from the display.
I see that in L183 the cell[2]
accumulated value gets Math.min
'd with the heat map's "max" value - which will effectively saturate the display for any non-sparse point field. That is to say, cell[2]
will quickly outgrow the "max" if more than one point is aggregated onto a cell.
This issue looks like it may be related to #65 also.
This bug is 9 month old. Which version works correct, as current is still incorrect?
People, isn't this critical or I miss something? Couldn't you write about this limitation in readme, instead praising how tiny and fast it is, so that we don't hit the wall, then google and browse issues to find nothing?
For other poor souls, I found that this plugin behaves as one would expected from heatmap: https://www.patrick-wied.at/static/heatmapjs/plugin-leaflet-layer.html
Although if you read this issue you are already aware perhaps...
Sorry, with so many open source repos to maintain, this went off my radar. I'm going to triage some issues in Leaflet.heat this week and hopefully fix or clear up the biggest hurdles.
Hi guy's,
I've submitted a pull request which potentially resolves this issue #78
It removes the max option and instead works it out for itself at each zoom level after points have been consolidated.
I have the same problem so far, what is the solution?