Change radius for a single point on Heatmap?
Asked Answered
T

2

6

Here is how you create Heatmap layer in Google Maps Api:

var data = [
        {location: new google.maps.LatLng(59.4072, 24.7053),weight:0.8},
        {location: new google.maps.LatLng(59.4372, 24.7473),weight: 1},
        {location: new google.maps.LatLng(59.4372, 24.7493),weight:0.8},
        {location: new google.maps.LatLng(59.483428, 24.841709),weight: 0.6},
        {location: new google.maps.LatLng(59.483256, 24.846666),weight: 0.2},
        {location: new google.maps.LatLng(59.409425, 27.278345),weight: 0.3}
    ];

heatmap = new google.maps.visualization.HeatmapLayer({
    data: data,
    radius: 10
});

As you can see, you have to specify radius in Heatmap config.
But how can I specify different radius for a single source (point) on the Heatmap?

Thief answered 8/5, 2015 at 9:11 Comment(2)
Can you make different "data" array and have assign it different radius?Proliferous
that won't work, because originally it expects radius to be in the heatmap configThief
B
0

Well in theory you could make multiple heatmap layers https://github.com/pa7/heatmap.js/issues/96#issuecomment-272202758

var data1 = [
    {location: new google.maps.LatLng(59.4072, 24.7053),weight:0.8},
    {location: new google.maps.LatLng(59.4372, 24.7473),weight: 1},
    {location: new google.maps.LatLng(59.4372, 24.7493),weight:0.8},
    {location: new google.maps.LatLng(59.483428, 24.841709),weight: 0.6},
    {location: new google.maps.LatLng(59.483256, 24.846666),weight: 0.2},
    {location: new google.maps.LatLng(59.409425, 27.278345),weight: 0.3}
];

heatmap1 = new google.maps.visualization.HeatmapLayer1({ data: data1, radius: 10 });

var data2 = [
    {location: new google.maps.LatLng(59.4072, 24.7053),weight:0.8},
    {location: new google.maps.LatLng(59.4372, 24.7473),weight: 1},
    {location: new google.maps.LatLng(59.4372, 24.7493),weight:0.8},
    {location: new google.maps.LatLng(59.483428, 24.841709),weight: 0.6},
    {location: new google.maps.LatLng(59.483256, 24.846666),weight: 0.2},
    {location: new google.maps.LatLng(59.409425, 27.278345),weight: 0.3}
];

heatmap2 = new google.maps.visualization.HeatmapLayer2({ data: data2, radius: 3 });

Bore answered 11/6, 2018 at 12:12 Comment(1)
I guess que question its to change the radius from each point, not just creating a tons and tons of maps just for that...Sesquialtera
S
0

Well, you can remove the radius from the config!

Example:

var heatMapData = [
  {location: new google.maps.LatLng(37.782, -122.447), weight: 0.5},
  {location: new google.maps.LatLng(37.782, -122.443), weight: 2}
];

heatmap = new google.maps.visualization.HeatmapLayer({
    data: heatMapData
});

You can find how to customize the heatmap layers > here <

Sesquialtera answered 2/8, 2021 at 14:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.