Reactjs 对地图实例的传单v3和传单上下文菜单插件问题作出反应
react-leavlet-v3中没有可用的映射实例 因此,传单上下文菜单 它不起作用 这个例子说明了我的问题Reactjs 对地图实例的传单v3和传单上下文菜单插件问题作出反应,reactjs,plugins,leaflet,react-leaflet,Reactjs,Plugins,Leaflet,React Leaflet,react-leavlet-v3中没有可用的映射实例 因此,传单上下文菜单 它不起作用 这个例子说明了我的问题 在MapContainer上创建时,可以使用属性获取地图实例 <MapContainer className="markercluster-map" center={currentLocation} zoom={zoom} maxZoom={18} contextmenu={tru
在MapContainer上创建时,可以使用
属性获取地图实例
<MapContainer
className="markercluster-map"
center={currentLocation}
zoom={zoom}
maxZoom={18}
contextmenu={true}
contextmenuItems={[
{
text: 'Zoom in',
callback: this.zoomIn
},
{ text: 'Zoom out', callback: this.zoomOut }
]}
whenCreated={(map) => this.setState({ map })}
>
...
</MapContainer>
它在中,只是有点难找到:
zoomOut = () => {
const { map } = this.state;
...
}
zoomIn = () => {
const { map } = this.state;
...
}