React-map-gl: map canvas position off (?)

Created on 22 Jul 2017  路  4Comments  路  Source: visgl/react-map-gl

Apologies if this is a trivial error...

Everytime I create a map, its canvas position is always off in respect to the parent element. As a result the map is only 1/2 the page width (see image below).

screen shot 2017-07-22 at 10 58 13

I've checked the CSS in the geojson example folder which works (the map stretches to the full page width) , and the style for all the HTML elements is the same as mine. Weirdly enough the width and height properties are correctly set by _onViewportChange() and _resize() methods, e.g.

``javascript _resize = () => { this.setState({ viewport: { ...this.state.viewport, width: this.props.width || window.innerWidth, height: this.props.height || window.innerHeight } }); }; ```` I'm using an ejectedcreate-react-app` with suggestions from issues #312 and #323 which work smoothly. I've found the same happening both in V2 and V3-beta

Any ideas why this might happen? Cheers!

Most helpful comment

@crunchex I had this issue also... A text-align style fixed it:

<ReactMapGL style={{textAlign: 'left'}} ...

All 4 comments

Closing this as I eventually found the issue to be related to simply conflicting methods between V2 and V3 + state management.

@miccferr good to hear this was resolved.

Feel free to propose improvements to our "Upgrade Guide" if you feel that some additional information there could have saved you time debugging this, maybe it will help someone else during their upgrade.

@miccferr I'm actually still having this problem using all the latest versions. Can you provide some more info regarding your solution if you can still recall?

@crunchex I had this issue also... A text-align style fixed it:

<ReactMapGL style={{textAlign: 'left'}} ...
Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamvdo picture iamvdo  路  5Comments

MattReimer picture MattReimer  路  3Comments

SethHamilton picture SethHamilton  路  3Comments

jenyeeiam picture jenyeeiam  路  4Comments

huaying picture huaying  路  5Comments