From affee2a8dd55fbb45df77ea81bce6ca186f67c45 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 24 Nov 2016 18:09:06 +0100 Subject: [PATCH] Keep original center on _mapDomResizeCallback (#282) When the resize event is triggered, the original center was lost. This issue is significant when the map is renders outside visible dom with zero height and width. When placed into the visible dom, the resize is triggered correctly. With this change the center will persist. (Without this fix the old center is the top left corner) --- src/google_map.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/google_map.js b/src/google_map.js index 6cdfe38..5394da4 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -391,7 +391,9 @@ export default class GoogleMap extends Component { _mapDomResizeCallback = () => { this.resetSizeOnIdle_ = true; if (this.maps_) { + const originalCenter = this.maps_.getCenter(); this.maps_.event.trigger(this.map_, 'resize'); + this.maps_.setCenter(originalCenter); } }