gpt4 book ai didi

javascript - 谷歌热图梯度范围?

转载 作者:行者123 更新时间:2023-11-28 07:53:29 24 4
gpt4 key购买 nike

我得到了城市人群的热图图层,我需要对热图上的人群进行排序,如何动态更改 Google 热图梯度?

var heatMapData = [
{location: new google.maps.LatLng(37.782, -122.447), weight: 50},
new google.maps.LatLng(37.782, -122.445),
{location: new google.maps.LatLng(37.782, -122.443), weight: 20},
{location: new google.maps.LatLng(37.782, -122.441), weight: 30},
{location: new google.maps.LatLng(37.782, -122.439), weight: 20},
new google.maps.LatLng(37.782, -122.437),
{location: new google.maps.LatLng(37.782, -122.435), weight: 55},

{location: new google.maps.LatLng(37.785, -122.447), weight: 30},
{location: new google.maps.LatLng(37.785, -122.445), weight: 20},
new google.maps.LatLng(37.785, -122.443),
{location: new google.maps.LatLng(37.785, -122.441), weight: 86},
new google.maps.LatLng(37.785, -122.439),
{location: new google.maps.LatLng(37.785, -122.437), weight: 20},
{location: new google.maps.LatLng(37.785, -122.435), weight: 20}
];

var sanFrancisco = new google.maps.LatLng(37.774546, -122.433523);

map = new google.maps.Map(document.getElementById('map-canvas'), {
center: sanFrancisco,
zoom: 13,
mapTypeId: google.maps.MapTypeId.SATELLITE
});

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

例如:我在热图上看起来的范围是 20 到 40?

最佳答案

使用此命令。更多信息here

 function changeGradient() {
var gradient = [
'rgba(0, 255, 255, 0)',
'rgba(0, 255, 255, 1)',
'rgba(0, 191, 255, 1)',
'rgba(0, 127, 255, 1)',
'rgba(0, 63, 255, 1)',
'rgba(0, 0, 255, 1)',
'rgba(0, 0, 223, 1)',
'rgba(0, 0, 191, 1)',
'rgba(0, 0, 159, 1)',
'rgba(0, 0, 127, 1)',
'rgba(63, 0, 91, 1)',
'rgba(127, 0, 63, 1)',
'rgba(191, 0, 31, 1)',
'rgba(255, 0, 0, 1)'
]
heatmap.set('gradient', heatmap.get('gradient') ? null : gradient);
}

关于javascript - 谷歌热图梯度范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26464316/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com