React-google-maps: Can I set "satellite" view as default?

Created on 23 May 2018  路  5Comments  路  Source: tomchentw/react-google-maps

I get that 'map' view but can I change it to be 'satellite' as default? I see I can change it manually in the UI but couldn't find that prop so it's always default

Most helpful comment

Namely this way:
<GoogleMapReact bootstrapURLKeys={{ key: =<<YOUR_API_KEY>>}} defaultCenter={this.props.center} defaultZoom={this.props.zoom} options={function (maps) { return { mapTypeId: "satellite" } }} > </GoogleMapReact>

All 5 comments

you can set "mapTypeId" in GoogleMap

Namely this way:
<GoogleMapReact bootstrapURLKeys={{ key: =<<YOUR_API_KEY>>}} defaultCenter={this.props.center} defaultZoom={this.props.zoom} options={function (maps) { return { mapTypeId: "satellite" } }} > </GoogleMapReact>

Both @AonanLi and @Edeph are correct. I would want to add a comment on top of Edeph's solution. It's better to use google.maps.MapTypeId.SATELLITE instead of the string "satellite" just to avoid typo.

Hey guys and how to know which map type is on?
I need something like this
google.maps.MapType === google.maps.MapTypeId.SATELLITE ? do something : do something

@enterthevoid

You can call getMapTypeId() from ref

<GoogleMap
            {...mapProps}
            ref={ref => {
                if (ref) {
                    console.log(ref.getMapTypeId());
                }
            }}
        >
            {children}
        </GoogleMap>

However, the default mapType Id is roadmap. Since you want to know which map type is on, you must have changed the map type by yourself, therefore you should already know what map type you are using.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shrimpy picture shrimpy  路  3Comments

craigcartmell picture craigcartmell  路  4Comments

tahir-masood1 picture tahir-masood1  路  4Comments

timkraut picture timkraut  路  3Comments

farhan687 picture farhan687  路  3Comments