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

jeroenpeeters picture jeroenpeeters  路  27Comments

spaceforestchu picture spaceforestchu  路  20Comments

tomchentw picture tomchentw  路  37Comments

sho13 picture sho13  路  42Comments

mmahalwy picture mmahalwy  路  19Comments