React-google-maps: Map not rendering

Created on 13 Nov 2016  路  4Comments  路  Source: tomchentw/react-google-maps

Hi,

My map is not rendering (I have a "blank screen").

Otherwise, I don't have any error in the console...

I added " <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=MY_KEY"></script>" in public\index.html

Here is my Js file:

import React, {Component } from 'react';
import logo from './logo.svg';
import './App.css';

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


const GettingStartedGoogleMap = withGoogleMap(props => (
    <GoogleMap
        defaultZoom={3}
        defaultCenter={{ lat: -25.363882, lng: 131.044922 }}
    >
    </GoogleMap>
));

class App extends Component {

    render() {

    return (

        <div style={{height: `100%`}}>
            <GettingStartedGoogleMap
                containerElement={
                    <div style={{ height: `100%` }} />
                }
                mapElement={
                    <div style={{ height: `100%` }} />
                }
            />
      </div>
    );
  }
}

export default App;

Thanks a lot for your help

Most helpful comment

I found a solution...

I changed the style of the container and the map like that :

 containerElement={
                    <div style={{    position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                        bottom: 0,
                        justifyContent: 'flex-end',
                        alignItems: 'center',}} />
                }
                mapElement={
                    <div style={{    position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                        bottom: 0,
                   }} />
                }

All 4 comments

I found a solution...

I changed the style of the container and the map like that :

 containerElement={
                    <div style={{    position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                        bottom: 0,
                        justifyContent: 'flex-end',
                        alignItems: 'center',}} />
                }
                mapElement={
                    <div style={{    position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                        bottom: 0,
                   }} />
                }

@Sachavent I ran into the same problem with the demo example.

@Pentatonic did you add my style?

To display a Mapview, you need "position : 'absolute' " (position relative may also work)

Please refer to Getting Help section in the README (or #469).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wayofthefuture picture wayofthefuture  路  3Comments

SyedSaifAli picture SyedSaifAli  路  3Comments

craigcartmell picture craigcartmell  路  4Comments

farhan687 picture farhan687  路  3Comments

0x1bitcrack3r picture 0x1bitcrack3r  路  3Comments