0
React-Leaflet documentation指定某些动态属性可以通过道具来设置。但是,有many other Leaflet properties/methods是可定制的......需要注意的是,为了访问它们,您需要直接与Leaflet实例交互(React-Leaflet文档中的mentioned here)。在React-Leaflet库中为<Map>组件设置选项的正确方法是什么?
我一直没能找到如何正确地做到这一点任何的例子,但我还是设法得到它的工作:
class SimpleExample extends React.Component {
...
componentDidMount(){
this.L.doubleClickZoom.disable();
this.L.zoomControl.setPosition('topright');
}
render() {
return <Map ref={(ref) => this.L = ref.getLeafletElement()} />
}
}
这是做到这一点的最好办法?