Skip to content

Commit

Permalink
Add possibility to update fixed zoom and center
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaZhidovKarelics committed Dec 8, 2023
1 parent 2b88fef commit 52dc6d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/Control.MiniMap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/Control.MiniMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@
this._miniMap.addLayer(this._layer);
},

updateFixedZoomLevel(zoomLevel) {
if (!this._isZoomLevelFixed()) {
throw new Error("Zoom level is not fixed");
}

this.options.zoomLevelFixed = zoomLevel;
this._decideZoom(true);
},

updateFixedCenter(center) {
if (!this._isCenterFixed()) {
throw new Error("Center is not fixed");
}

this.options.centerFixed = center;
this._miniMap.setView(center, this._decideZoom(true));
},

_addToggleButton: function () {
this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton(
'', this._toggleButtonInitialTitleText(), ('leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' +
Expand Down Expand Up @@ -262,6 +280,8 @@
},

_onMiniMapMoved: function (e) {
if (this.options.centerFixed) return;

if (!this._mainMapMoving) {
this._miniMapMoving = true;
this._mainMap.setView(this._miniMap.getCenter(), this._decideZoom(false));
Expand All @@ -276,6 +296,10 @@
return this._isDefined(zoomLevelFixed) && this._isInteger(zoomLevelFixed);
},

_isCenterFixed: function () {
return this._isDefined(this.options.centerFixed);
},

_decideZoom: function (fromMaintoMini) {
if (!this._isZoomLevelFixed()) {
if (fromMaintoMini) {
Expand Down

0 comments on commit 52dc6d5

Please sign in to comment.