【发布时间】:2019-08-20 10:57:31
【问题描述】:
我正在通过“h3.geoToH3(lng, lat, res)”生成一组十六进制 ID。 之后我通过“让多边形= 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
})
}
【问题讨论】:
标签: h3