Google地图热图的单个半径

时间:2014-09-04 21:21:21

标签: javascript google-maps google-maps-api-3 heatmap

我使用谷歌地图javascript v3 api,我试图使用这个api热图层制作热图应用程序。 在我的应用程序中,我需要每个位置(加权的lanlng位置)具有自己的半径。正如我在文档中看到的那样,为整个图层设置了radius属性(热图图层中所有位置的半径相同)。拥有多个热图图层并不是一个好的解决方案,因为它会使应用程序过于缓慢。有什么想法吗?

谢谢, 鹭

1 个答案:

答案 0 :(得分: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 });
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 });