From 949736af9b1ec22bfabf0586097c26bae5427c30 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 11 May 2016 19:08:21 +1200 Subject: [PATCH 1/2] Added support for minZoomOverride flag. If set to true, the minZoom option will be used instead of being calculated. --- src/google_map.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/google_map.js b/src/google_map.js index 60d8b0f..0597072 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -306,6 +306,13 @@ export default class GoogleMap extends Component { return DEFAULT_MIN_ZOOM; } + _computeMinZoom = (minZoomOverride, minZoom) => { + if (minZoomOverride) { + return minZoom ? minZoom : DEFAULT_MIN_ZOOM; + } + return this._getMinZoom(); + } + _initMap = () => { // only initialize the map once if (this.initialized_) { @@ -356,7 +363,7 @@ export default class GoogleMap extends Component { const draggableOptions = this.props.draggable !== undefined && {draggable: this.props.draggable}; - const minZoom = this._getMinZoom(); + const minZoom = this._computeMinZoom(options.minZoomOverride, options.minZoom); this.minZoom_ = minZoom; const preMapOptions = { @@ -494,7 +501,9 @@ export default class GoogleMap extends Component { maps.event.addListener(map, 'idle', () => { if (this.resetSizeOnIdle_) { this._setViewSize(); - const currMinZoom = this._getMinZoom(); + const currMinZoom = this._computeMinZoom( + this.props.options.minZoomOverride, + this.props.options.minZoom); if (currMinZoom !== this.minZoom_) { this.minZoom_ = currMinZoom; From b2671d185affb99de8d3158986fefa1f7ad24a12 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 11 May 2016 20:26:25 +1200 Subject: [PATCH 2/2] add a section in README about overriding minimum zoom --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 34d3d3e..6c3d817 100644 --- a/README.md +++ b/README.md @@ -385,6 +385,21 @@ and if so, uses it, so it won't load a second copy of the library. ``` +### Override the default minimum zoom + +*WARNING*: Setting these options can break markers calculation, causing no homeomorphism between screen coordinates and map. + +You can use the `minZoomOverride` associated with the `minZoom` in the custom map options to prevent a minimum zoom from being calculated: + +```javascript +function createMapOptions() { + return { + minZoomOverride: true, + minZoom: 2, + }; +} +``` + --- (*Really big thanks to [April Arcus](https://github.com/AprilArcus) for documentation fixes*)