简体   繁体   中英

Heatmap.js with leaflet. Max Value not working as expected

I have a leaflet map with a heatmap . Everything is working perfectly except for the max value of the heatmap.

So let's say I have 30 points with a value going from 4 to 15

{'lat':x,'lng':y,'value':5},{'lat':x,'lng':y,'value':10}...etc

And my max is 15. So that would mean that my point with value 15 would be the red point right?

var heatData = {
   max: maxNumber,
   data: heatPoints
}

That works as expected.

However, if I change my max to 1000 I would expect all my points to go towards the blue color since no point is close to 1000.

That doesn't work as expected. Here is a demo: http://jsfiddle.net/pvanb/rgb4dagp/

Try changing the max value and you'll see the heatmap stays the same.

Is this a bug or is there something I'm not doing correctly?

Sorry I figured it out myself. You have to set useLocalExtrema to false in the config:

var cfg = {           
                "radius": 0.2,
                "maxOpacity": .8, 
                "scaleRadius": true, 
                "useLocalExtrema": false,
                latField: 'lat',
                lngField: 'lng',
                valueField: 'count'
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM