Lock / retain specified center on resize#308
Lock / retain specified center on resize#308Marcel-G wants to merge 5 commits intogoogle-map-react:masterfrom Marcel-G:master
Conversation
adding note about `resetBoundsOnResize` to readme (#307)
| const currentCenter = this.map_.getCenter(); | ||
| this.maps_.event.trigger(this.map_, 'resize'); | ||
| this.map_.setCenter(originalCenter); | ||
| this.map_.setCenter(this.props.lockCenter ? originalCenter : currentCenter); |
There was a problem hiding this comment.
@Marcel-G This PR is looking good! But it is throwing an error in this line on Travis CI:
460:27 error Follow `prettier` formatting (expected '\n' but found 't') prettier/prettier
Would you mind checking on that?
There was a problem hiding this comment.
@itsmichaeldiego, thanks for stepping up as a new maintainer! I've already upgraded to the latest version, thanks to the fix in #452 (comment). However, I need to get this fix landed as well before I can actually take advantage of the fullscreen functionality.
The CI error can be fixed by running yarn lint --fix, or applying the following patch:
diff --git a/src/google_map.js b/src/google_map.js
index aba1ea5..e4a8b8c 100644
--- a/src/google_map.js
+++ b/src/google_map.js
@@ -457,7 +457,9 @@ export default class GoogleMap extends Component {
const originalCenter = this.props.center || this.props.defaultCenter;
const currentCenter = this.map_.getCenter();
this.maps_.event.trigger(this.map_, 'resize');
- this.map_.setCenter(this.props.lockCenter ? originalCenter : currentCenter);
+ this.map_.setCenter(
+ this.props.lockCenter ? originalCenter : currentCenter
+ );
}
};
Would you like me to submit a separate PR?
There was a problem hiding this comment.
@josephfrazier Thanks for the kind words. This fix seems like the solution to our problems. Feel free to make a PR, that would be awesome! We would also need a modification in the docs so users know they're able to use lockCenter
|
Hi I reckon this is caused by detectElementResize that detects the original element instead of the resized/full screen map element test url: tested I'm using google-map-react v0.34.0 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
#282
Some way to keep the map centered on center / default center prop when _mapDomResizeCallback is called would be useful.
I'm using google-map-react with panControl and dragging disabled, therefore the center cannot change from user input. When the map is resized, I want the map to center on the center prop given to google-map-react not getCenter()