如何按数据值设置Mapbox热图颜色?

如何按数据值设置Mapbox热图颜色?,mapbox,mapbox-gl,Mapbox,Mapbox Gl,我想显示蓝牙扫描的热图,这样强信号扫描显示为绿色,弱信号扫描显示为红色。我尝试过使用Mapbox的所有热图属性(重量、强度、半径、颜色、不透明度),但未能达到此效果。关于如何做,有什么建议吗 GeoJSON数据格式(“rssi”是信号强度) 到目前为止的热图层 map.addLayer({ id: 'heatmap_heatmap_layer_id', type: 'heatmap', source: 'heatmap_source_id',

我想显示蓝牙扫描的热图,这样强信号扫描显示为绿色,弱信号扫描显示为红色。我尝试过使用Mapbox的所有热图属性(重量、强度、半径、颜色、不透明度),但未能达到此效果。关于如何做,有什么建议吗

GeoJSON数据格式(“rssi”是信号强度)

到目前为止的热图层

map.addLayer({
        id: 'heatmap_heatmap_layer_id',
        type: 'heatmap',
        source: 'heatmap_source_id',
        maxzoom: 24,
        paint: {
          'heatmap-weight': {
            property: 'rssi',
            type: 'exponential',
            stops: [
              [0, 1],
              [120, 10]
            ]
          },
          'heatmap-intensity': {
            stops: [
              [currentZoom, 1],
              [24, 2]
            ]
          },
          'heatmap-color': [
            'interpolate',
            ['linear'],
            ['heatmap-density'],
            0, 'rgba(240,29,29,0)',
            0.2, 'rgba(198,0,12,1)', 
            0.4, 'rgba(32,43,222,1)', 
            0.7, 'rgba(1,1,1,1)', 
            1.0, 'rgba(200,144,153,1)'
          ],
          'heatmap-radius': {
            stops: [
              [currentZoom, 20],
              [middleZoom, 30]
            ]
          },
          'heatmap-opacity': {
            default: 1,
            stops: [
              [currentZoom, 1],
              [24, 1]
            ]
          },
        }
      });

这个有点棘手,因为热图会自动混合并添加彼此非常接近的点。这意味着单个强信号点将显示相同的颜色,因为许多弱信号点靠近在一起


您最好将点可视化为离散圆,用RSSI着色。

这一点有点棘手,因为热图会自动混合并添加彼此非常接近的点。这意味着单个强信号点将显示相同的颜色,因为许多弱信号点靠近在一起


您最好将这些点视为离散的圆,并用RSSI着色。

理想情况下,当缩小时,许多弱信号点靠近会形成一个单一的弱区域。换句话说,颜色将代表区域中各点的平均信号强度,而不是总和。如果我找不到这个问题的解决方案,我可能会尝试你的建议,使用离散圆。@SoftwareStudent123你能找到解决方案吗?如果是的话,如果你能回答自己的问题,为他人着想,那就太好了:)如果不是的话,离散圆在放大或缩小时在视觉上是如何工作的?理想情况下,当缩小时,许多微弱信号点靠在一起会形成一个单一的弱区域。换句话说,颜色将代表区域中各点的平均信号强度,而不是总和。如果我找不到这个问题的解决方案,我可能会尝试你的建议,使用离散圆。@SoftwareStudent123你能找到解决方案吗?如果是的话,如果你能回答自己的问题,为他人着想,那就太好了:)如果不是的话,离散圆在放大或缩小时是如何在视觉上为你工作的?
map.addLayer({
        id: 'heatmap_heatmap_layer_id',
        type: 'heatmap',
        source: 'heatmap_source_id',
        maxzoom: 24,
        paint: {
          'heatmap-weight': {
            property: 'rssi',
            type: 'exponential',
            stops: [
              [0, 1],
              [120, 10]
            ]
          },
          'heatmap-intensity': {
            stops: [
              [currentZoom, 1],
              [24, 2]
            ]
          },
          'heatmap-color': [
            'interpolate',
            ['linear'],
            ['heatmap-density'],
            0, 'rgba(240,29,29,0)',
            0.2, 'rgba(198,0,12,1)', 
            0.4, 'rgba(32,43,222,1)', 
            0.7, 'rgba(1,1,1,1)', 
            1.0, 'rgba(200,144,153,1)'
          ],
          'heatmap-radius': {
            stops: [
              [currentZoom, 20],
              [middleZoom, 30]
            ]
          },
          'heatmap-opacity': {
            default: 1,
            stops: [
              [currentZoom, 1],
              [24, 1]
            ]
          },
        }
      });