Skip to content

Programmatically change center #40

Closed Answered by giorgiabosello
bradley-varol asked this question in Help
Discussion options

You must be logged in to vote

You need to use the methods inside the mapRef to change the map after being initialized.
Example:

const mapRef = useRef(null)

const onGoogleApiLoaded = ({ map }) => {
    mapRef.current = map
    mapRef.current.setCenter(new lat/lng)
}

return (
  <GoogleMap
    // options
    onGoogleApiLoaded={onGoogleApiLoaded}
  ></GoogleMap>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bradley-varol
Comment options

@bradley-varol
Comment options

@giorgiabosello
Comment options

Answer selected by bradley-varol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #39 on March 29, 2023 15:33.