mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
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:
parent
1211f98bf8
commit
faf67e5e0e
5
API.md
5
API.md
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user