How do you call fitBounds() when using leaflet-react?
问题 I cannot figure out how to call fitBounds() on the Leaflet map. If I was just using vanilla leaflet, this solution would work perfectly: Zoom to fit all markers in Mapbox or Leaflet Unfortunately, I am using react-leaflet. Here is the solution if I was just using leaflet by itself. var leafletMap = new L.featureGroup([marker1, marker2, marker3]); map.fitBounds(leafletMap.getBounds()); I think this code (my code) this.mapRef.current.leafletElement is equivalent to var leafletMap = new L