fitBounds(): void { const points = this.props.points; const lngs = map(points, this.props.longitudeExtractor); const lats = map(points, this.props.latitudeExtractor); const ne = { lng: max(lngs), lat: max(lats) }; const sw = { lng: min(lngs), lat: min(lats) }; if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) { return; } this.props.leaflet.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne))); }
componentDidMount() { const props = omit(this.props, OTHER_PROPS) this.leafletElement = this.createLeafletElement(props) this.leafletElement.on('move', this.onViewportChange) this.leafletElement.on('moveend', this.onViewportChanged) if (props.bounds != null) { this.leafletElement.fitBounds(props.bounds, props.boundsOptions) } if (this.props.whenReady) { this.leafletElement.whenReady(this.props.whenReady) } this.contextValue = { layerContainer: this.leafletElement, map: this.leafletElement, } super.componentDidMount() this.forceUpdate() // Re-render now that leafletElement is created }
this.leafletElement.flyToBounds(bounds, boundsOptions) } else { this.leafletElement.fitBounds(bounds, boundsOptions)