Accept 0 as zoom value. (#525)

* Accept zoom being 0

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

* Oops! Wrong operators
This commit is contained in:
Michael Diego 2018-03-09 11:08:46 -08:00 committed by GitHub
parent 1211f98bf8
commit faf67e5e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

5
API.md
View File

@ -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,
};
}

View File

@ -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);
}
@ -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();
};
@ -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 = {
@ -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
);