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

Can't implement Styling Wizard #37

Open
fdurmaz opened this issue Jun 17, 2018 · 3 comments
Open

Can't implement Styling Wizard #37

fdurmaz opened this issue Jun 17, 2018 · 3 comments

Comments

@fdurmaz
Copy link

fdurmaz commented Jun 17, 2018

Hello,

I'm using the Custom Styling Wizard to get the silver style map. However, when I try to implement the JSON file to my project, it doesn't work.

This is my file:

// Packages
import React, {Component} from 'react';
import GoogleMapReact from 'google-map-react';

export default class Map extends Component {
    static defaultProps = {
        center: {lat: 51.909490, lng: 6.384903},
        zoom: 8,
        styles: require('../../constants/mapStyles')
    }


    render() {
        return (
            <div className='google-map' style={{height: '100vh', width: '100%'}}>
                <GoogleMapReact
                    bootstrapURLKeys={{key: 'AIzaSyClAqaUdtOKdG6zyT8wSNkuBhm1iOcfaVw'}}
                    defaultCenter={this.props.center}
                    defaultZoom={this.props.zoom}
                    defaultOptions={this.props.styles}>
                </GoogleMapReact>
            </div>
        )
    }
}
@fdurmaz fdurmaz changed the title Styling Wizard Can't implement Styling Wizard Jun 17, 2018
@johanlef
Copy link

DId you try: defaultOptions={{ styles: this.props.styles }}?

options accepts an object, you are probably passing the mapStyles array directly, without key.

@fdurmaz
Copy link
Author

fdurmaz commented Jun 23, 2018

@johanlef I've tried. Nothing works..

@hansott
Copy link

hansott commented Feb 28, 2019

mapStyles.js:

export default [
  {
    elementType: "geometry",
    stylers: [
      {
        color: "#f5f5f5",
      },
    ],
  },
  // ...
];
import styles from "./mapStyles";

<GoogleMapReact
  bootstrapURLKeys={{ key: GOOGLE_MAPS_API_KEY }}
  options={{ styles }}
>
  {/* your markers */}
</GoogleMapReact>

or options={{ styles: styles }}

works perfectly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants