Skip to content

Commit

Permalink
Accept 0 as zoom value. (#525)
Browse files Browse the repository at this point in the history
* Accept zoom being 0

* If we set a minZoom, its clear that we want to override it

* Oops! Wrong operators
  • Loading branch information
itsmichaeldiego committed Mar 9, 2018
1 parent 1211f98 commit faf67e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
5 changes: 2 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,13 @@ 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.
*WARNING*: Setting this option 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:
You can use the `minZoom` custom option to prevent our minimum-zoom calculation:

```javascript
function createMapOptions() {
return {
minZoomOverride: true,
minZoom: 2,
};
}
Expand Down
17 changes: 5 additions & 12 deletions src/google_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@ export default class GoogleMap extends Component {
options = omit(options, ['zoom', 'center', 'draggable']);

if ('minZoom' in options) {
const minZoom = this._computeMinZoom(
options.minZoomOverride,
options.minZoom
);
const minZoom = this._computeMinZoom(options.minZoom);
options.minZoom = _checkMinZoom(options.minZoom, minZoom);
}

Expand Down Expand Up @@ -453,9 +450,9 @@ export default class GoogleMap extends Component {
return DEFAULT_MIN_ZOOM;
};

_computeMinZoom = (minZoomOverride, minZoom) => {
if (minZoomOverride) {
return minZoom || DEFAULT_MIN_ZOOM;
_computeMinZoom = minZoom => {
if (minZoom !== undefined && minZoom !== null) {
return minZoom;
}
return this._getMinZoom();
};
Expand Down Expand Up @@ -546,10 +543,7 @@ export default class GoogleMap extends Component {
draggable: this.props.draggable,
};

const minZoom = this._computeMinZoom(
options.minZoomOverride,
options.minZoom
);
const minZoom = this._computeMinZoom(options.minZoom);
this.minZoom_ = minZoom;

const preMapOptions = {
Expand Down Expand Up @@ -700,7 +694,6 @@ export default class GoogleMap extends Component {
if (this.resetSizeOnIdle_) {
this._setViewSize();
const currMinZoom = this._computeMinZoom(
this.props.options.minZoomOverride,
this.props.options.minZoom
);

Expand Down

0 comments on commit faf67e5

Please sign in to comment.