Hi! I just found this repo and am implementing it in a project I'm working on. Runs very smooth, thanks for this!
However, I want to apply my own map style to the map, and I fail to see how/where I can do that. Any ideas on how/if that can be done?
Also, where do I put other props for the map/markers, like icon for marker, assigning an info window to it and opening it on click etc? I noticed there seems to be a component called InfoWindow, but I couldn't find any documentation about it.
Thanks in advance, and thanks for the great repo!
@zth do you refer to stuff like this?
https://tomchentw.github.io/react-google-maps/#events/event-closure
@zth You can apply all google.map options as props to a <GoogleMap />. For example:
<GoogleMap mapStyles={/* YOUR MAP STYLES*/} />
Not mapStyles but styles.
Close this due to inactivity. Thanks @JanKantyPawelski to point that out.
For me adding styles as a prop didn't work. I had to add the styles to the defaultOptions prop as one can see in this example.
https://github.com/tomchentw/react-google-maps/blob/master/src/app/pages/basics/StyledMapExample.js
It is also possible to add the custom styles to the options prop as options.styles.
you can find this on here its really useful and easy to use
https://github.com/tomchentw/react-google-maps/blob/master/src/app/constants/fancyMapStyles.json
If one of you can update your links that would make my night :D
New example:
https://tomchentw.github.io/react-google-maps/#!/InfoBox
Please read the documentation site first!
How can i add custom style on the GoogleMap
import {withGoogleMap, GoogleMap, Marker, Polyline} from "react-google-maps";
is not working
Hey I am not sure if I actually ever got this working, because I know right
now I just have a greyscale filter. But Here is what my component
looks like[image:
Inline image 1]
where styles is [image: Inline image 2]
You can find/ create different mapstyle.json on Google map developer site.
Good luck!
On Tue, Nov 14, 2017 at 1:54 AM, Win Sandy Myint notifications@github.com
wrote:
@anusree-mmlab https://github.com/anusree-mmlab
const exampleMapStyles = [] //Add some style
defaultOptions={{ styles: exampleMapStyles }}
>Example here https://tomchentw.github.io/react-google-maps/#!/InfoBox
Check fancy map styles here https://snazzymaps.com/—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/tomchentw/react-google-maps/issues/53#issuecomment-344174297,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AT-vXIBmM0k1Hc5tzZ9H0jiQw6noiOwNks5s2UdQgaJpZM4EclFw
.
@winsandymyint you did it! love you ❤️
It is possible using the following way:
const exampleMapStyles = [{
featureType: "water",
elementType: "labels.text.fill",
stylers: [
{
color: "#9e9e9e",
},
],
}] //Add some style
<GoogleMap
options={{ styles: exampleMapStyles }}
>
I can confirm @anusree-mmlab method worked for me.
Just put your JSON style into a JS file as so:
export const MyStyle = [ YOUR STYLES HERE]
Then, in your map component:
import { MyStyle } from './MyStyle';
// other stuff
<GoogleMap defaultOptions={{ styles: MyStyle }}
defaultZoom={8}
defaultCenter={{ lat: -34.397, lng: 150.644 }} />
Little late to the party but nothing I do seems to quite work. I gave up on having ...
Style data as JSON (from snazzy maps) and placed within a exported variable named "greyMap" and saved the file as mapStyles.js
I then imported it into a component the GoogleMaps component is in import { greyMap } from "./mapStyles"
With my GoogleMaps component looking like
`
zoom={9}
center={hasLocation ? currentLocation : center}
onLoad={(map) => setMapRef(map)}
styles={greyMap}
`
I tried defaultOptions={{ style: greyMap }} and got the same results. Not sure what I'm doing wrong!
@coderdix The repo of this project is unmaintained more than a year, and we had build new version https://www.npmjs.com/package/@react-google-maps/api
We had rewrite it to TypeScript, and updating it frequently: https://github.com/JustFly1984/react-google-maps-api/tree/master/packages/react-google-maps-api
You can enjoy autocomplete.
You can see our docs: https://react-google-maps-api-docs.netlify.app
Also a lot of examples: https://react-google-maps-api-gatsby-demo.netlify.app/ https://github.com/JustFly1984/react-google-maps-api/tree/master/packages/react-google-maps-api-gatsby-example/src/examples
The bundle size is much smaller: https://bundlephobia.com/result?p=@react-google-maps/api
Our Spectrum community: https://spectrum.chat/react-google-maps Our Slack channel: https://join.slack.com/t/react-google-maps-api/shared_invite/enQtODc5ODU1NTY5MzQ4LTBiNTYzZmY1YmVjYzJhZThkMGU0YzUwZjJkNGJmYjk4YjQyYjZhMDk2YThlZGEzNDc0M2RhNjBmMWE4ZTJiMjQ
Enjoy!
I'm using that one I keep searching when I have an issue and posting on the wrong forum lol
Most helpful comment
@anusree-mmlab
Example here
Check fancy map styles here