Programmatically change center #40
-
Describe the feature you'd like to requestIn How do we navigate the map to a lat/lng? Describe the solution you'd likeDescribe alternatives you've considered |
Beta Was this translation helpful? Give feedback.
Answered by
giorgiabosello
Mar 29, 2023
Replies: 1 comment 3 replies
-
You need to use the methods inside the mapRef to change the map after being initialized. const mapRef = useRef(null)
const onGoogleApiLoaded = ({ map }) => {
mapRef.current = map
mapRef.current.setCenter(new lat/lng)
}
return (
<GoogleMap
// options
onGoogleApiLoaded={onGoogleApiLoaded}
></GoogleMap> |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
bradley-varol
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to use the methods inside the mapRef to change the map after being initialized.
Example: