Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mapId option. #1086

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/google_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this


if ('minZoom' in options) {
const minZoom = this._computeMinZoom(options.minZoom);
options.minZoom = _checkMinZoom(options.minZoom, minZoom);
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down