我正在通过“h3.geoToH3(lng, lat, res)”生成一组十六进制 ID。之后,我通过“let polygons = geojson2h3.h3SetToFeatureCollection(hexIds)”创建一个 FeatureCollection 当我点击地图上的一个六边形时,我只想要启动的六边形内的相关六边形的 ID。我怎样才能以高效的方式做到这一点?
getHexIds = (res) => {
let hexIds = this.props.stations.features.map(element => {
const [lng, lat] = element.geometry.coordinates;
const hexId = h3.geoToH3(lng, lat, res);
return hexId;
})
let polygons = geojson2h3.h3SetToFeatureCollection(hexIds);
this.setState({
polygons: polygons
}, () => {
this.geoJsonLayer.current.leafletElement.clearLayers().addData(this.state.polygons);
})
// console.info(this.state.polygons, res);
}
onEachFeature = (feature, layer) => {
layer.on('click', (e) => {
// show the relevant hexids
})
}