GithubHelp home page GithubHelp logo

Comments (20)

winsandymyint avatar winsandymyint commented on September 26, 2024 39

@anusree-mmlab

const exampleMapStyles = [] //Add some style  
<GoogleMap
    defaultOptions={{ styles: exampleMapStyles }}
    >

Example here
Check fancy map styles here

from react-google-maps.

frankbo avatar frankbo commented on September 26, 2024 21

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.

from react-google-maps.

joshuawootonn avatar joshuawootonn commented on September 26, 2024 10

If one of you can update your links that would make my night :D

from react-google-maps.

anusree-mmlab avatar anusree-mmlab commented on September 26, 2024 9

How can i add custom style on the GoogleMap

import {withGoogleMap, GoogleMap, Marker, Polyline} from "react-google-maps";

<GoogleMap
mapStyles=[style object]

is not working

from react-google-maps.

asmmahmud avatar asmmahmud commented on September 26, 2024 7

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 }}
    >

from react-google-maps.

mrjosshi avatar mrjosshi commented on September 26, 2024 6

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

from react-google-maps.

jankanty avatar jankanty commented on September 26, 2024 2

Not mapStyles but styles.

from react-google-maps.

glmagicworks avatar glmagicworks commented on September 26, 2024 1

@winsandymyint you did it! love you ❤️

from react-google-maps.

baughmann avatar baughmann commented on September 26, 2024 1

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 }} />

from react-google-maps.

JustFly1984 avatar JustFly1984 commented on September 26, 2024 1

@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!

from react-google-maps.

tomchentw avatar tomchentw commented on September 26, 2024

@zth do you refer to stuff like this?

Custom map style:

http://git.io/vTkmW

Marker and InfoWindow

https://tomchentw.github.io/react-google-maps/#events/event-closure

from react-google-maps.

wuct avatar wuct commented on September 26, 2024

@zth You can apply all google.map options as props to a <GoogleMap />. For example:

<GoogleMap mapStyles={/* YOUR MAP STYLES*/} />

from react-google-maps.

tomchentw avatar tomchentw commented on September 26, 2024

Close this due to inactivity. Thanks @JanKantyPawelski to point that out.

from react-google-maps.

tomchentw avatar tomchentw commented on September 26, 2024

New example:
https://tomchentw.github.io/react-google-maps/#!/InfoBox

Please read the documentation site first!

from react-google-maps.

joshuawootonn avatar joshuawootonn commented on September 26, 2024

from react-google-maps.

coderdix avatar coderdix commented on September 26, 2024

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
<GoogleMap id="map" 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!

from react-google-maps.

coderdix avatar coderdix commented on September 26, 2024

I'm using that one I keep searching when I have an issue and posting on the wrong forum lol

from react-google-maps.

yhoungdev avatar yhoungdev commented on September 26, 2024

my map keeps overflowing

from react-google-maps.

glmagicworks avatar glmagicworks commented on September 26, 2024

my map keeps overflowing

Can you please provide a screenshoot? And also the code you used in the example for us to be able to reproduce it...

from react-google-maps.

jesusbubai25 avatar jesusbubai25 commented on September 26, 2024

my map keeps overflowing

Add position property as relative in mapContainerStyle props it will not overflow

from react-google-maps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.