antvis / LarkMap

A React toolkit for geospatial visualization based on L7.

Home Page:https://larkmap.antv.antgroup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🤔 [QUESTION] 为什么 heatlayer 热力图层的feature始终为null

ThorSmallice opened this issue · comments

"@antv/l7": "^2.15.3",
"@antv/larkmap": "^1.3.5",
"react": "^18.2.0",
包信息如上,
同一个点,同一份数据,textLayer点击事件可以获取到feature,heatlayer 获取的feature为null
image
const layerOptions: Omit<HeatmapLayerProps, 'source'> = {
autoFit: true,
shape: 'heatmap' as const,

  size: {
      field: 'radius',
  },

  style: {
      intensity: 3,
      radius: 10,
      opacity: 1,
      rampColors: {
          colors: ['#95de64', '#52c41a', '#ffc069', '#fa8c16', '#ff7875', '#f5222d'],
          positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
      },
  },
  state: {
      active: true,
  },

}
<HeatmapLayer
onClick={(e) => {
console.log(e, 'heatmap clicked')
}}
ref={ref}
id="minganpointHeatlayer"
name="敏感点"
{...layerOptions}
source={source}

const textlayerOptions: Omit<TextLayerProps, 'source'> = {
autoFit: true,
field: 'val',
style: {
fill: {
field: 'val',
value: ['#95de64', '#52c41a', '#ffc069', '#fa8c16', '#ff7875', '#f5222d'],
},
opacity: 1,
fontSize: 14,
textAllowOverlap: false,
padding: [10, 10] as [number, number],
},
}

<TextLayer
{...textlayerOptions}
source={source}
onClick={(e) => {
console.log(e, 'textlayer click')
}}
/>

heatlayer 尝试过用layer.getSource();
source.getFeatureById(featureId); 结果也是null

commented

@ThorSmallice 热力图层没有数据拾取能力,可以在热力图层下面盖一层点图层来实现拾取