Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing props to withGoogleMap's defaultCenter #453

Closed
jupiterkenji opened this issue Mar 27, 2017 · 2 comments
Closed

Passing props to withGoogleMap's defaultCenter #453

jupiterkenji opened this issue Mar 27, 2017 · 2 comments

Comments

@jupiterkenji
Copy link

Hi there, I'm just starting to use react. I can't seem to pass my component props's lat and lng to withGoogleMap's GoogleMap defaultCenter?
The map just show grey color.

const GettingStartedGoogleMap = withGoogleMap(props => (
	<GoogleMap
    	ref={props.onMapLoad}
    	defaultZoom={10}
    	//defaultCenter={{ lat: -25.363882, lng: 131.044922 }} // this works
    	defaultCenter={{ lat: parseFloat(props.mapLocation.lat), lng: parseFloat(props.mapLocation.lng) }} // this is not working
  	>
  	</GoogleMap>

...

        render() {
	    const { location } = this.props;

    	if (location != undefined) {
	    	return <div>
	      		<h1>Locations</h1>
	      		Name: {location.name} <br />
	      		Location: {location.lat}, {location.lng} <br />

		      	<div style={{height: '100%'}}>
			        <GettingStartedGoogleMap
			        	containerElement={
			            	<div style={{ height: '100%' }} />
			          	}
			          	mapElement={
			            	<div style={{ height: '100%' }} />
			          	}
			          	onMapClick={this.handleMapClick}
          				onMarkerRightClick={this.handleMarkerRightClick}
			          	mapLocation={location}
			          	onMapLoad={this.handleMapLoad}
			        />
		    	</div>

	    	</div>
    	}

    	return null;
  	}
));

any one experience such thing? or my understanding is not right?

@petertdinh
Copy link

mapLocation isn't a valid prop. Try position={location}

@tomchentw
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants