Google-maps-react: How to update center map?

Created on 13 Mar 2018  路  2Comments  路  Source: fullstackreact/google-maps-react

i set center map lat =0, long =0. then i set center map with my location but map can't update center position.

Most helpful comment

oh, solved. i take props onReady={(mapProps, map)=>this.fetchPlaces(mapProps, map)} on map. then i create function :
fetchPlaces(mapProps, map) {
var center = new google.maps.LatLng(this.props.lat, this.props.lon);
map.panTo(center);
}

All 2 comments

oh, solved. i take props onReady={(mapProps, map)=>this.fetchPlaces(mapProps, map)} on map. then i create function :
fetchPlaces(mapProps, map) {
var center = new google.maps.LatLng(this.props.lat, this.props.lon);
map.panTo(center);
}

I add this.state.map.setCenter(marker.getPosition()); to marker click event marker.addListener('click', () => {}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t1a2l picture t1a2l  路  5Comments

EmmaU25 picture EmmaU25  路  3Comments

kkinaman picture kkinaman  路  3Comments

lishi500 picture lishi500  路  4Comments

joeyfigaro picture joeyfigaro  路  3Comments