Skip to content

Commit ac243e5

Browse files
committed
Prevents map from initializing twice
1 parent cfdc8d6 commit ac243e5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/google_map.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export default class GoogleMap extends Component {
130130
constructor(props) {
131131
super(props);
132132
this.mounted_ = false;
133+
this.initialized_ = false;
133134

134135
this.map_ = null;
135136
this.maps_ = null;
@@ -318,6 +319,12 @@ export default class GoogleMap extends Component {
318319
}
319320

320321
_initMap = () => {
322+
// only initialize the map once
323+
if (this.initialized_) {
324+
return;
325+
}
326+
this.initialized_ = true;
327+
321328
const propsCenter = latLng2Obj(this.props.center || this.props.defaultCenter);
322329
this.geoService_.setView(propsCenter, this.props.zoom || this.props.defaultZoom, 0);
323330

0 commit comments

Comments
 (0)