From fc11c295b3221b54fa35f81c1b640da3814e3b0f Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Sun, 9 Jan 2022 00:30:50 -0700 Subject: [PATCH] omit styles when mapId is present --- src/google_map.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/google_map.js b/src/google_map.js index 17da6316..cdaf82d4 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -388,6 +388,14 @@ class GoogleMap extends Component { // remove zoom, center and draggable options as these are managed by google-maps-react options = omit(options, ['zoom', 'center', 'draggable']); + // A Map's styles property cannot be set when a mapId is present. + // When a mapId is present Map styles are controlled via the cloud console. + if ('mapId' in options) { + options = omit(options, ['styles']); + } + + console.log('options', options); + if ('minZoom' in options) { const minZoom = this._computeMinZoom(options.minZoom); options.minZoom = _checkMinZoom(options.minZoom, minZoom); @@ -585,7 +593,7 @@ class GoogleMap extends Component { // "MaxZoomStatus", "StreetViewStatus", "TransitMode", "TransitRoutePreference", // "TravelMode", "UnitSystem" const mapPlainObjects = pick(maps, isPlainObject); - const options = + let options = typeof this.props.options === 'function' ? this.props.options(mapPlainObjects) : this.props.options; @@ -598,6 +606,12 @@ class GoogleMap extends Component { const minZoom = this._computeMinZoom(options.minZoom); this.minZoom_ = minZoom; + // A Map's styles property cannot be set when a mapId is present. + // When a mapId is present Map styles are controlled via the cloud console. + if ('mapId' in options) { + options = omit(options, ['styles']); + } + const preMapOptions = { ...defaultOptions, minZoom,