VLeaflet gradient and values

Good day to all,

I’m playing around with Vleaflet Heat and so far so good. This being said, when doing my tests, I’m having these questions rise up :

First, here is some of my code to get into context (parts of it) :

final GlobalSession lSessionData = ui.getGlobalSession();
LMap map = lSessionData.getLeafletMap();
List on

LHeatMapLayer heatlayer = new LHeatMapLayer();
List heatpoints = new ArrayList<>();

for (OneNews iter : on) {
heatpoints.add(new Point3D(iter.getLatitude(), iter.getLongitude(), iter.getAttending_count()));
}

heatlayer.setPoints(heatpoints.toArray(new Point[0]
));

HashMap<Double,String> gradient = new LinkedHashMap<>();

    gradient.put(0.4, "blue");
    gradient.put(0.65, "lime");
    gradient.put(1.0, "red");
    heatlayer.setGradient(gradient);
    heatlayer.setRadius(35);
    heatlayer.setBlur(25);

map.addBaseLayer(heatlayer, “Heat Map”);

Here is my question : I don’t see anywhere on how to inject values associated to intensity. well … I do … But When I try it doesn’t work as I want it to.

In essence, I know I can inject intensity : heatpoints.add(new Point3D(iter.getLatitude(), iter.getLongitude(), iter.getAttending_count()));

in this case iter.getAttending_count() is similar to a population

BUT … If I do this, then my gradient values don’t fit anymore with the population values :

    gradient.put(0.4, "blue");
    gradient.put(0.65, "lime");
    gradient.put(1.0, "red");

Since population is pretty much always over 1, I get this mostly red heatmap. So my problem is that I don’t know in advance what gradient values I should put. Also the default value of the heatlayer.setMax(maxvalue) is defaulted to 1. Even if I raise it to … Well … Which value ???

Am I missing something ?

Cheers

Norm.

Hi Norm,

Did you check if the examples/documentation in original JS library helps?


https://github.com/Leaflet/Leaflet.heat

cheers,
matti