Prevents map from initializing twice

This commit is contained in:
Anders Stalheim Øfsdahl 2016-01-16 01:40:12 +01:00
parent cfdc8d6168
commit ac243e5668

View File

@ -130,6 +130,7 @@ export default class GoogleMap extends Component {
constructor(props) {
super(props);
this.mounted_ = false;
this.initialized_ = false;
this.map_ = null;
this.maps_ = null;
@ -318,6 +319,12 @@ export default class GoogleMap extends Component {
}
_initMap = () => {
// only initialize the map once
if (this.initialized_) {
return;
}
this.initialized_ = true;
const propsCenter = latLng2Obj(this.props.center || this.props.defaultCenter);
this.geoService_.setView(propsCenter, this.props.zoom || this.props.defaultZoom, 0);