React-google-maps: None of the UI control props are working

Created on 20 Dec 2015  路  3Comments  路  Source: tomchentw/react-google-maps

I'm trying to disable all the buttons on the map:

<GoogleMap mapTypeControl={false} panControl={false} streetViewControl={false} zoomControl={false}/>

None of those props seem to have any affect.

Most helpful comment

The react-google-maps documentation does not explain exactly how to do this.

Here is how you need to code the component:

  <GoogleMap
    defaultZoom={12}
    defaultCenter={{ lat: 48.855924, lng: 2.34532 }}
    defaultOptions={{
      styles: mapStyle,
     // these following 7 options turn certain controls off see link below
      streetViewControl: false,
      scaleControl: false,
      mapTypeControl: false,
      panControl: false,
      zoomControl: false,
      rotateControl: false,
      fullscreenControl: false
    }}
    disableDefaultUI />

A list of all available control options you can turn on/off are here: https://developers.google.com/maps/documentation/javascript/controls#Adding_Controls_to_the_Map

All 3 comments

Oops, nevermind. Looks like those needs to go into the options props.

Yes, options are the right place. Thanks!

The react-google-maps documentation does not explain exactly how to do this.

Here is how you need to code the component:

  <GoogleMap
    defaultZoom={12}
    defaultCenter={{ lat: 48.855924, lng: 2.34532 }}
    defaultOptions={{
      styles: mapStyle,
     // these following 7 options turn certain controls off see link below
      streetViewControl: false,
      scaleControl: false,
      mapTypeControl: false,
      panControl: false,
      zoomControl: false,
      rotateControl: false,
      fullscreenControl: false
    }}
    disableDefaultUI />

A list of all available control options you can turn on/off are here: https://developers.google.com/maps/documentation/javascript/controls#Adding_Controls_to_the_Map

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julienvincent picture julienvincent  路  3Comments

ShintaroNippon picture ShintaroNippon  路  3Comments

craigcartmell picture craigcartmell  路  4Comments

wayofthefuture picture wayofthefuture  路  3Comments

farhan687 picture farhan687  路  3Comments