在热力图上更改单个点的半径?

5
这里是如何在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
});

正如您所看到的,您需要在热力图配置中指定半径。
但是,我该如何为热力图上的单个源(点)指定不同的半径?


你能创建不同的“数据”数组并为其分配不同的半径吗? - Verma
那样做是行不通的,因为原本它期望热力图配置中有“半径”这个参数。 - Michael
2个回答

0

理论上,您可以创建多个热力图层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 });

热力图1 = 新的google.maps.visualization.HeatmapLayer1({ 数据:data1, 半径: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 });

热力图2 = 新的google.maps.visualization.HeatmapLayer2({ 数据:data2, 半径:3 });

我猜问题是要改变每个点的半径,而不是为此创建大量的地图... - Lucas Martini

0

好的,你可以从配置中删除半径!

示例:

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
});

您可以在这里找到如何自定义热图层 > 此处 <


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接