Skip to content

Commit

Permalink
Option 'initialZoomLevel': zoom to specified zoom level after click
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Mar 21, 2020
1 parent c1b0a7d commit ff034f7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/L.Control.Locate.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
setView: 'untilPanOrZoom',
/** Keep the current map zoom level when setting the view and only pan. */
keepCurrentZoomLevel: false,
/** After activating the plugin by clicking on the icon, zoom to the selected zoom level, even when keepCurrentZoomLevel is true. Set to 'false' to disable this feature. */
initialZoomLevel: false,
/**
* This callback can be used to override the viewport tracking
* This function should return a LatLngBounds object.
Expand Down Expand Up @@ -525,6 +527,10 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
this._event = undefined; // clear the current location so we can get back into the bounds
this.options.onLocationOutsideMapBounds(this);
} else {
if (this._justClicked && this.options.initialZoomLevel !== false) {
var f = this.options.flyTo ? this._map.flyTo : this._map.setView;
f.bind(this._map)([this._event.latitude, this._event.longitude], this.options.initialZoomLevel);
} else
if (this.options.keepCurrentZoomLevel) {
var f = this.options.flyTo ? this._map.flyTo : this._map.panTo;
f.bind(this._map)([this._event.latitude, this._event.longitude]);
Expand Down

0 comments on commit ff034f7

Please sign in to comment.