Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add worldCopyJumpCenter option to Map #6723

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/map/handler/Map.Drag.js
Expand Up @@ -44,6 +44,13 @@ Map.mergeOptions({
// like markers and vector layers are still visible.
worldCopyJump: false,

// @option worldCopyJumpCenter: Number = 0.0
// If worldCopyJump is enabled, this option sets the central longitude that
// the map will jump to stay near. For example, if your map is focused on
// the Pacific, you could add all your features with longitudes in the
// range [0,360] and set worldCopyJumpCenter to 180.
worldCopyJumpCenter: 0.0,

// @option maxBoundsViscosity: Number = 0.0
// If `maxBounds` is set, this option will control how solid the bounds
// are when dragging the map around. The default value of `0.0` allows the
Expand Down Expand Up @@ -146,7 +153,8 @@ export var Drag = Handler.extend({

_onZoomEnd: function () {
var pxCenter = this._map.getSize().divideBy(2),
pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
lng = this._map.options.worldCopyJumpCenter,
pxWorldCenter = this._map.latLngToLayerPoint([0, lng]);

this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
this._worldWidth = this._map.getPixelWorldBounds().getSize().x;
Expand Down