Leaflet.VectorTileLayer包装后可在react-leaflet中使用。叠加层中有一堆这些图块层,还有一些其他层使用react-leaflet的GeoJSON组件导入直接json数据。一切正常,但如果我先加载geojson图层,则会失去矢量图块图层的交互性。加载正常但不可点击的图层或其他样式选项未在地图中呈现。无需加载geojson图层,它们就可以正常工作。
代码中的简单用法:
<Overlay name="Turkey Counties">
<TRCountiesGeoJSON ref="TRCountiesGeoJSON" />
</Overlay>
<Overlay name="Sentinel-2 Grid">
<WrappedVectorTileLayer {...sentineloptions}
// onClick={function (layer) {
// console.log("layer: ", layer);
// }}
onClick={(e) => this.handleSentinelGridClick(e)}
url={this.state.geojsonUrl + "/sentinel2grid/{z}/{x}/{y}.pbf"}
/>
</Overlay>
矢量图块实现来自@willfalconer的repository