How to get bounds with react-leaflet

后端 未结 1 956
余生分开走
余生分开走 2020-12-20 12:51

I want to get bounds of the current map so that I can search those bounds with the Overpass API.

For leaflet I know the method is just map.getBounds(), but I don\'t

相关标签:
1条回答
  • 2020-12-20 13:18

    Try this.refs.map.leafletElement.getBounds.

    According to the documentation:

    You can directly access the Leaflet element created by a component using this.leafletElement in this component. This leaflet element is usually created in componentWillMount(), except for the Map component where it can only be created after the container is rendered.

    which is a round about way of saying they store the leaflet object as leafletElement property on their component objects.

    0 讨论(0)
提交回复
热议问题