From 4bec957eb42b048dc5a45b9d9970f11dfc2b9681 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 24 Nov 2016 15:58:47 +0100 Subject: [PATCH] Keep original center on _mapDomResizeCallback 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 eafdf40e..f6ce4fb3 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -390,7 +390,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); } }