react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

MapTypeId is not set from props if mapOptions is used

Open gson88 opened this issue 7 years ago • 4 comments

Please provide an explanation

props.mapTypeId on GoogleMap does not do any difference if props.mapOptions (without mapTypeId) is passed to the component.

Your Environment

os: mac

node --version 11.7

react version 16.8.6

webpack version 4.34

@babel version 7.4.5

@react-google-maps/api version 1.7.7

How is it behave?

The map type on google maps is always set to "roadmap" if mapOptions (without mapTypeId) is passed to the GoogleMaps-component

How should it behave correctly?

The prop mapTypeId on GoogleMaps should be the one that is passed down to google-maps, even though a mapOptions is present.

gson88 avatar Oct 15 '19 15:10 gson88

@gson88 Can you please provide minimal reproduction on codesandbox?

JustFly1984 avatar Oct 25 '19 23:10 JustFly1984

@JustFly1984 I certainly can, sorry for not providing one from the beginning. https://codesandbox.io/s/usegooglemap-repro-gyt0k mapTypeId is set to "hybrid", but the mapTypeId being set on the map is "roadmap"

gson88 avatar Oct 27 '19 16:10 gson88

I also just ran into this issue. But I was able to get around it by just always including "mapTypeId" into the mapOptions and stopped passing it into the map.

dogofpavlov avatar Oct 29 '19 21:10 dogofpavlov

@dogofpavlov Yeah that is possible. The problem for us is that we don't have the global google-object when the mapOptions-object is created (we want to create the object outside of the component to prevent re-rendering). We solved it by setting the mapType when the map had loaded instead.

gson88 avatar Oct 31 '19 15:10 gson88