Google-maps-react: styling is overwritten from the javascript

Created on 19 Jul 2016  Â·  11Comments  Â·  Source: fullstackreact/google-maps-react

I am not sure how you managed to apply the styles in the yelp clone demo.

The JS keeps applying 100% to width and height and position: absolute every time a Map is rendered.

Most helpful comment

Anyone know how to remove the width and height 100% on the parent div ?
I override the styles but it recreate a parent div to override my override.

All 11 comments

Ah, yes... this is inside the component itself here: https://github.com/fullstackreact/google-maps-react/blob/master/src/index.js#L177

You can override this default or perhaps it makes sense to create an option to apply these styles conditionally.

What do you think?

I think a flag that is passable to the option is a good idea, if it is passed false it will apply no styles from the source component.

Thank you for your response. Great work with this.

Sure. Wanna try a PR, @Szarko ?

bump ^^

Did anyone fix this? I can't for the life of me set the position to 'relative'. Would fix all my problems. Tried changing the css, internal css, and it keeps forcing 'absolute'.

@TheMaverickProgrammer did you manage to fix it? I struggled with this for a while but made it work. I took out the const style from Container and just put style={{height: '100vh', width: '100vw'}} directly into the render function in Map, on the line above 'Loading map...." and below <div ref='map'>

No I wrote my own

    I’ll remove the default styling in the js and leave it up to the user to define styles. 



    Cheers!

Ari Lernercurl -IL http://ari.io

On Wed, Sep 27, 2017 at 1:11 PM -0700, "Maverick Peppers" notifications@github.com wrote:

No I wrote my own

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Anyone know how to remove the width and height 100% on the parent div ?
I override the styles but it recreate a parent div to override my override.

The best way to fix this issue is this.
Apply className to the Map component.
And then define css style to the class.

<Map className="miniMap"/>

In the css file define css rules to the miniMap class

.miniMap {
  position: relative !important;
  with: 100% !important;
  height: 400px !important;
}

No I wrote my own

hey @TheMaverickProgrammer can you publish the source code for the map component?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t1a2l picture t1a2l  Â·  5Comments

mruoss picture mruoss  Â·  5Comments

anushreepatil picture anushreepatil  Â·  5Comments

antonk52 picture antonk52  Â·  5Comments

ktosiek picture ktosiek  Â·  3Comments