谷歌热图梯度范围

Google heatmap gradient range?

本文关键字:范围 谷歌      更新时间:2023-09-26

我得到了一个城市人的热图层,我需要在热图上对范围内的人进行排序,我如何动态更改谷歌热图梯度?

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不等?

使用此命令。更多信息点击这里

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