Cant set center of the map.
See original GitHub issueI am trying to set the center of the map but to no success. What am i doing wrong? The map marker is positioned to geolocation but center is not changing.
classSimpleMapPage extends Component {
mixins: [PureRenderMixin];
constructor () {
super();
this.state = {
center: {
lat: 23.938043,
lng: 73.337157
},
zoom: 14
};
}
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
center: {
lat: position.coords.latitude,
lng: position.coords.longitude
}
}
);
// var center = this.state.center;
// center.lat = position.coords.latitude;
// center.lng = position.coords.longitude;
// this.setState({center: center});
},
(error) => { console.log(error.message),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
}
render() {
return (
<GoogleMap center={this.state.center} zoom={this.state.zoom} >
<MapMarker lat={this.state.center.lat} lng={this.state.center.lng} text={'Me'}/>
</GoogleMap>
);
}
};`
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
How come my setCenter doesn't work? - Stack Overflow
But map.setCenter won't work. I thought it was because I wasn't calling LatLng parameters correctly, but discovered it won't work even if I ......
Read more >Map.setCenter - Earth Engine - Google Developers
Centers the map view at a given coordinates with the given zoom level. ... Set the position and optional zoom level of the...
Read more >Recentering map not working - Google Groups
"map.setCenter" doesn't work. The map reloads but stays at the old center (you can see it both on the map ... any different...
Read more >Fix a missing address or wrong pin location - Google Maps Help
You can publicly add or edit addresses in Maps. Add mailing addresses, fix ... Move the map to the center of the building....
Read more >Configure the map—ArcGIS Field Maps | Documentation
Map areas, sharing settings, and the Hide in Field Maps mobile setting are not ... If you add the same layer to your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Works for me https://jsbin.com/ledujubibe/edit?js,console,output
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.