Comments (20)
const exampleMapStyles = [] //Add some style
<GoogleMap
defaultOptions={{ styles: exampleMapStyles }}
>
Example here
Check fancy map styles here
from react-google-maps.
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.
If one of you can update your links that would make my night :D
from react-google-maps.
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.
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.
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.
Not mapStyles
but styles
.
from react-google-maps.
@winsandymyint you did it! love you ❤️
from react-google-maps.
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.
@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.
@zth do you refer to stuff like this?
Custom map style:
Marker and InfoWindow
https://tomchentw.github.io/react-google-maps/#events/event-closure
from react-google-maps.
@zth You can apply all google.map
options as props
to a <GoogleMap />
. For example:
<GoogleMap mapStyles={/* YOUR MAP STYLES*/} />
from react-google-maps.
Close this due to inactivity. Thanks @JanKantyPawelski to point that out.
from react-google-maps.
New example:
https://tomchentw.github.io/react-google-maps/#!/InfoBox
Please read the documentation site first!
from react-google-maps.
from react-google-maps.
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.
I'm using that one I keep searching when I have an issue and posting on the wrong forum lol
from react-google-maps.
my map keeps overflowing
from react-google-maps.
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.
my map keeps overflowing
Add position property as relative in mapContainerStyle props it will not overflow
from react-google-maps.
Related Issues (20)
- how to add button re center on map HOT 1
- Problems while implementing Content Security Policy HOT 1
- Polygon not being drawn on the map HOT 1
- CWE-601 Security Vulnerability found in one of the transitive dependencies HOT 1
- Legacy context API has been detected within a strict-mode tree. HOT 1
- AutoComplete Default Value
- Check this use 'window'
- Error when installing HOT 3
- Could not resolve dependency: npm ERR! peer react@"^16 || ^17" from [email protected]
- Problem in Installation HOT 2
- I can not push custom control button to the map
- More than 700 re renderings HOT 1
- Is there any benefits to using MarkerClusterer, rather than simply using Markers?
- Best Way To Style Marker Labels?
- KMlLayer 2d, 3d kmz file or kml file highlighted layer not showing
- f.setPosition is not a function
- How can I get the DOM element for Marker?
- disable map zoom when DirectionsRenderer redraws the path
- Upgrade jQuery dependency inside scriptjs package. HOT 1
- Update needed?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-google-maps.