From ac243e56682a8fa7c39cfbd08aefe8d625aabbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Stalheim=20=C3=98fsdahl?= Date: Sat, 16 Jan 2016 01:40:12 +0100 Subject: [PATCH] Prevents map from initializing twice --- src/google_map.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/google_map.js b/src/google_map.js index 422f5a0..cd31c15 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -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);