First thank you all for this great library
the issue: fitBounds is not in typescript typings
if i import { fitBounds } from 'google-map-react/utils';
typescript complains with Could not find a declaration file for module 'google-map-react/utils'.
i don't know if maybe i'm importing it wrong.
Thank you for your time.
@edgarjrg i use google maps own fitBounds method for this.
First off you need to tell GoogleMapReact to use GoogleMapApi:
private googleMaps: google.maps.Map;
public render() {
return (
<GoogleMapReact
onGoogleApiLoaded={this.handleGoogleApiLoaded}
yesIWantToUseGoogleMapApiInternals={true}
...
>
{some component}
</GoogleMapReact
);
}
then:
private handleGoogleApiLoaded(maps: { map: google.maps.Map; }) {
this.googleMaps = maps.map;
const bounds = {
north: boundingBox[1].latitude,
east: boundingBox[1].longitude,
south: boundingBox[0].latitude,
west: boundingBox[0].longitude,
};
this.googleMaps.fitBounds(bounds);
}
the typings are coming from:
"@types/googlemaps": "3.30.x",
Thank you @vertic4l ! I'm able to use this.googleMaps.fitBounds as well as google-map-react/utils/fitBound just fine, what i'm asking is for the typings of google-map-react/utils/fitBound that is not related to this.googleMaps.fitBounds
The file is https://github.com/google-map-react/google-map-react/blob/master/src/utils/utils.js
and is documented here https://github.com/google-map-react/google-map-react/blob/master/API.md#utility-functions
@edgarjrg I would recommend you to use googleMaps.fitBounds, something like how I did it here in google-map-react-examples
Most helpful comment
@edgarjrg I would recommend you to use googleMaps.fitBounds, something like how I did it here in google-map-react-examples