@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -6
- package/es/index.d.ts +3 -4
- package/es/index.js +2 -4
- package/es/map/camera.d.ts +690 -0
- package/es/map/camera.js +1138 -0
- package/{lib → es/map}/css/l7.css +41 -7
- package/es/map/events.d.ts +384 -0
- package/es/map/events.js +222 -0
- package/es/map/geo/edge_insets.d.ts +97 -0
- package/es/{geo → map/geo}/edge_insets.js +55 -33
- package/es/map/geo/lng_lat.d.ts +116 -0
- package/es/map/geo/lng_lat.js +159 -0
- package/es/map/geo/lng_lat_bounds.d.ts +217 -0
- package/es/map/geo/lng_lat_bounds.js +334 -0
- package/es/map/geo/mercator_coordinate.d.ts +113 -0
- package/es/map/geo/mercator_coordinate.js +142 -0
- package/es/map/geo/transform.d.ts +262 -0
- package/es/map/geo/transform.js +736 -0
- package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
- package/es/map/handler/box_zoom.js +145 -0
- package/es/map/handler/click_zoom.d.ts +24 -0
- package/es/map/handler/click_zoom.js +47 -0
- package/es/map/handler/cooperative_gestures.d.ts +40 -0
- package/es/map/handler/cooperative_gestures.js +94 -0
- package/es/map/handler/drag_handler.d.ts +88 -0
- package/es/map/handler/drag_handler.js +89 -0
- package/es/map/handler/drag_move_state_manager.d.ts +30 -0
- package/es/map/handler/drag_move_state_manager.js +94 -0
- package/es/map/handler/handler_util.d.ts +3 -0
- package/es/{handler → map/handler}/handler_util.js +1 -2
- package/es/map/handler/keyboard.d.ts +88 -0
- package/es/map/handler/keyboard.js +197 -0
- package/es/map/handler/map_event.d.ts +46 -0
- package/es/map/handler/map_event.js +131 -0
- package/es/map/handler/mouse.d.ts +30 -0
- package/es/map/handler/mouse.js +85 -0
- package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/es/map/handler/one_finger_touch_drag.js +39 -0
- package/es/map/handler/scroll_zoom.d.ts +102 -0
- package/es/map/handler/scroll_zoom.js +312 -0
- package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
- package/es/map/handler/shim/drag_pan.d.ts +79 -0
- package/es/map/handler/shim/drag_pan.js +77 -0
- package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/es/map/handler/shim/drag_rotate.js +66 -0
- package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/es/map/handler/shim/two_fingers_touch.js +106 -0
- package/es/map/handler/tap_drag_zoom.d.ts +28 -0
- package/es/map/handler/tap_drag_zoom.js +92 -0
- package/es/map/handler/tap_recognizer.d.ts +35 -0
- package/es/map/handler/tap_recognizer.js +107 -0
- package/es/map/handler/tap_zoom.d.ts +28 -0
- package/es/map/handler/tap_zoom.js +87 -0
- package/es/map/handler/touch_pan.d.ts +40 -0
- package/es/map/handler/touch_pan.js +85 -0
- package/es/map/handler/transform-provider.d.ts +23 -0
- package/es/map/handler/transform-provider.js +35 -0
- package/es/map/handler/two_fingers_touch.d.ts +107 -0
- package/es/map/handler/two_fingers_touch.js +289 -0
- package/es/map/handler_inertia.d.ts +20 -0
- package/es/{handler → map}/handler_inertia.js +36 -50
- package/es/map/handler_manager.d.ts +154 -0
- package/es/map/handler_manager.js +466 -0
- package/es/map/map.d.ts +625 -0
- package/es/map/map.js +972 -0
- package/es/map/util/abort_error.d.ts +15 -0
- package/es/map/util/abort_error.js +21 -0
- package/es/map/util/browser.d.ts +10 -0
- package/es/map/util/browser.js +30 -0
- package/es/map/util/dom.d.ts +30 -0
- package/es/map/util/dom.js +105 -0
- package/es/map/util/evented.d.ts +75 -0
- package/es/map/util/evented.js +158 -0
- package/es/map/util/task_queue.d.ts +18 -0
- package/es/map/util/task_queue.js +54 -0
- package/es/map/util/util.d.ts +104 -0
- package/es/map/util/util.js +155 -0
- package/lib/index.d.ts +3 -4
- package/lib/index.js +12 -42
- package/lib/map/camera.d.ts +690 -0
- package/lib/map/camera.js +1145 -0
- package/{es → lib/map}/css/l7.css +41 -7
- package/lib/map/events.d.ts +384 -0
- package/lib/map/events.js +231 -0
- package/lib/map/geo/edge_insets.d.ts +97 -0
- package/lib/{geo → map/geo}/edge_insets.js +56 -35
- package/lib/map/geo/lng_lat.d.ts +116 -0
- package/lib/map/geo/lng_lat.js +166 -0
- package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
- package/lib/map/geo/lng_lat_bounds.js +341 -0
- package/lib/map/geo/mercator_coordinate.d.ts +113 -0
- package/lib/map/geo/mercator_coordinate.js +157 -0
- package/lib/map/geo/transform.d.ts +262 -0
- package/lib/map/geo/transform.js +744 -0
- package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
- package/lib/map/handler/box_zoom.js +153 -0
- package/lib/map/handler/click_zoom.d.ts +24 -0
- package/lib/map/handler/click_zoom.js +54 -0
- package/lib/map/handler/cooperative_gestures.d.ts +40 -0
- package/lib/map/handler/cooperative_gestures.js +101 -0
- package/lib/map/handler/drag_handler.d.ts +88 -0
- package/lib/map/handler/drag_handler.js +97 -0
- package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
- package/lib/map/handler/drag_move_state_manager.js +103 -0
- package/lib/map/handler/handler_util.d.ts +3 -0
- package/lib/{handler → map/handler}/handler_util.js +1 -2
- package/lib/map/handler/keyboard.d.ts +88 -0
- package/lib/map/handler/keyboard.js +205 -0
- package/lib/map/handler/map_event.d.ts +46 -0
- package/lib/map/handler/map_event.js +140 -0
- package/lib/map/handler/mouse.d.ts +30 -0
- package/lib/map/handler/mouse.js +93 -0
- package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/lib/map/handler/one_finger_touch_drag.js +47 -0
- package/lib/map/handler/scroll_zoom.d.ts +102 -0
- package/lib/map/handler/scroll_zoom.js +320 -0
- package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
- package/lib/map/handler/shim/drag_pan.d.ts +79 -0
- package/lib/map/handler/shim/drag_pan.js +85 -0
- package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/lib/map/handler/shim/drag_rotate.js +74 -0
- package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/lib/map/handler/shim/two_fingers_touch.js +114 -0
- package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
- package/lib/map/handler/tap_drag_zoom.js +99 -0
- package/lib/map/handler/tap_recognizer.d.ts +35 -0
- package/lib/map/handler/tap_recognizer.js +116 -0
- package/lib/map/handler/tap_zoom.d.ts +28 -0
- package/lib/map/handler/tap_zoom.js +94 -0
- package/lib/map/handler/touch_pan.d.ts +40 -0
- package/lib/map/handler/touch_pan.js +92 -0
- package/lib/map/handler/transform-provider.d.ts +23 -0
- package/lib/map/handler/transform-provider.js +43 -0
- package/lib/map/handler/two_fingers_touch.d.ts +107 -0
- package/lib/map/handler/two_fingers_touch.js +296 -0
- package/lib/map/handler_inertia.d.ts +20 -0
- package/lib/{handler → map}/handler_inertia.js +38 -53
- package/lib/map/handler_manager.d.ts +154 -0
- package/lib/map/handler_manager.js +474 -0
- package/lib/map/map.d.ts +625 -0
- package/lib/map/map.js +979 -0
- package/lib/map/util/abort_error.d.ts +15 -0
- package/lib/map/util/abort_error.js +29 -0
- package/lib/map/util/browser.d.ts +10 -0
- package/lib/map/util/browser.js +36 -0
- package/lib/map/util/dom.d.ts +30 -0
- package/lib/map/util/dom.js +113 -0
- package/lib/map/util/evented.d.ts +75 -0
- package/lib/map/util/evented.js +167 -0
- package/lib/map/util/task_queue.d.ts +18 -0
- package/lib/map/util/task_queue.js +62 -0
- package/lib/map/util/util.d.ts +104 -0
- package/lib/map/util/util.js +171 -0
- package/package.json +6 -3
- package/es/camera.d.ts +0 -86
- package/es/camera.js +0 -639
- package/es/earthmap.d.ts +0 -69
- package/es/earthmap.js +0 -445
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -59
- package/es/geo/lng_lat_bounds.d.ts +0 -25
- package/es/geo/lng_lat_bounds.js +0 -118
- package/es/geo/mercator.d.ts +0 -30
- package/es/geo/mercator.js +0 -72
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -153
- package/es/geo/simple.d.ts +0 -30
- package/es/geo/simple.js +0 -75
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -895
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -58
- package/es/handler/box_zoom.js +0 -162
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -40
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -12
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -4
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -45
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -33
- package/es/handler/events/render_event.d.ts +0 -6
- package/es/handler/events/render_event.js +0 -10
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_manager.d.ts +0 -61
- package/es/handler/handler_manager.js +0 -487
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -131
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -89
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -4
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -99
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -21
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -24
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -24
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -315
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -75
- package/es/handler/shim/drag_rotate.js +0 -64
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -104
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -77
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -89
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -46
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -81
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -5
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -91
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -75
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -57
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -37
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -98
- package/es/hash.d.ts +0 -14
- package/es/hash.js +0 -121
- package/es/interface.d.ts +0 -34
- package/es/interface.js +0 -1
- package/es/map.d.ts +0 -70
- package/es/map.js +0 -472
- package/es/util.d.ts +0 -25
- package/es/util.js +0 -70
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -72
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -117
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -58
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -37
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -60
- package/lib/camera.d.ts +0 -86
- package/lib/camera.js +0 -648
- package/lib/earthmap.d.ts +0 -69
- package/lib/earthmap.js +0 -451
- package/lib/geo/edge_insets.d.ts +0 -54
- package/lib/geo/lng_lat.d.ts +0 -18
- package/lib/geo/lng_lat.js +0 -67
- package/lib/geo/lng_lat_bounds.d.ts +0 -25
- package/lib/geo/lng_lat_bounds.js +0 -126
- package/lib/geo/mercator.d.ts +0 -30
- package/lib/geo/mercator.js +0 -88
- package/lib/geo/point.d.ts +0 -40
- package/lib/geo/point.js +0 -161
- package/lib/geo/simple.d.ts +0 -30
- package/lib/geo/simple.js +0 -92
- package/lib/geo/transform.d.ts +0 -198
- package/lib/geo/transform.js +0 -906
- package/lib/handler/IHandler.d.ts +0 -34
- package/lib/handler/IHandler.js +0 -5
- package/lib/handler/blockable_map_event.d.ts +0 -17
- package/lib/handler/blockable_map_event.js +0 -66
- package/lib/handler/box_zoom.js +0 -168
- package/lib/handler/click_zoom.d.ts +0 -16
- package/lib/handler/click_zoom.js +0 -48
- package/lib/handler/events/event.d.ts +0 -4
- package/lib/handler/events/event.js +0 -20
- package/lib/handler/events/index.d.ts +0 -4
- package/lib/handler/events/index.js +0 -27
- package/lib/handler/events/map_mouse_event.d.ts +0 -34
- package/lib/handler/events/map_mouse_event.js +0 -53
- package/lib/handler/events/map_touch_event.d.ts +0 -57
- package/lib/handler/events/map_touch_event.js +0 -83
- package/lib/handler/events/map_wheel_event.d.ts +0 -33
- package/lib/handler/events/map_wheel_event.js +0 -41
- package/lib/handler/events/render_event.d.ts +0 -6
- package/lib/handler/events/render_event.js +0 -18
- package/lib/handler/handler_inertia.d.ts +0 -23
- package/lib/handler/handler_manager.d.ts +0 -61
- package/lib/handler/handler_manager.js +0 -495
- package/lib/handler/handler_util.d.ts +0 -4
- package/lib/handler/keyboard.d.ts +0 -36
- package/lib/handler/keyboard.js +0 -138
- package/lib/handler/map_event.d.ts +0 -29
- package/lib/handler/map_event.js +0 -97
- package/lib/handler/mouse/index.d.ts +0 -4
- package/lib/handler/mouse/index.js +0 -27
- package/lib/handler/mouse/mouse_handler.d.ts +0 -22
- package/lib/handler/mouse/mouse_handler.js +0 -107
- package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
- package/lib/handler/mouse/mousepan_handler.js +0 -29
- package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/lib/handler/mouse/mousepitch_hander.js +0 -32
- package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/lib/handler/mouse/mouserotate_hander.js +0 -32
- package/lib/handler/mouse/util.d.ts +0 -6
- package/lib/handler/mouse/util.js +0 -19
- package/lib/handler/scroll_zoom.d.ts +0 -93
- package/lib/handler/scroll_zoom.js +0 -322
- package/lib/handler/shim/drag_pan.d.ts +0 -61
- package/lib/handler/shim/drag_pan.js +0 -83
- package/lib/handler/shim/drag_rotate.js +0 -72
- package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/lib/handler/shim/touch_zoom_rotate.js +0 -112
- package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/lib/handler/tap/single_tap_recognizer.js +0 -86
- package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_drag_zoom.js +0 -97
- package/lib/handler/tap/tap_recognizer.d.ts +0 -17
- package/lib/handler/tap/tap_recognizer.js +0 -56
- package/lib/handler/tap/tap_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_zoom.js +0 -89
- package/lib/handler/touch/index.d.ts +0 -5
- package/lib/handler/touch/index.js +0 -34
- package/lib/handler/touch/touch_pan.d.ts +0 -30
- package/lib/handler/touch/touch_pan.js +0 -100
- package/lib/handler/touch/touch_pitch.d.ts +0 -13
- package/lib/handler/touch/touch_pitch.js +0 -83
- package/lib/handler/touch/touch_rotate.d.ts +0 -12
- package/lib/handler/touch/touch_rotate.js +0 -65
- package/lib/handler/touch/touch_zoom.d.ts +0 -12
- package/lib/handler/touch/touch_zoom.js +0 -45
- package/lib/handler/touch/two_touch.d.ts +0 -23
- package/lib/handler/touch/two_touch.js +0 -106
- package/lib/hash.d.ts +0 -14
- package/lib/hash.js +0 -129
- package/lib/interface.d.ts +0 -34
- package/lib/interface.js +0 -5
- package/lib/map.d.ts +0 -70
- package/lib/map.js +0 -478
- package/lib/util.d.ts +0 -25
- package/lib/util.js +0 -89
- package/lib/utils/Aabb.d.ts +0 -12
- package/lib/utils/Aabb.js +0 -80
- package/lib/utils/dom.d.ts +0 -4
- package/lib/utils/dom.js +0 -125
- package/lib/utils/performance.d.ts +0 -17
- package/lib/utils/performance.js +0 -64
- package/lib/utils/primitives.d.ts +0 -6
- package/lib/utils/primitives.js +0 -45
- package/lib/utils/task_queue.d.ts +0 -13
- package/lib/utils/task_queue.js +0 -67
package/es/camera.js
DELETED
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import { lodashUtil } from '@antv/l7-utils';
|
|
4
|
-
import { EventEmitter } from 'eventemitter3';
|
|
5
|
-
import LngLat from "./geo/lng_lat";
|
|
6
|
-
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
7
|
-
import Point from "./geo/point";
|
|
8
|
-
import Transform from "./geo/transform";
|
|
9
|
-
import { Event } from "./handler/events/event";
|
|
10
|
-
import { clamp, ease as defaultEasing, extend, interpolate, now, pick, prefersReducedMotion, wrap } from "./util";
|
|
11
|
-
const {
|
|
12
|
-
merge
|
|
13
|
-
} = lodashUtil;
|
|
14
|
-
export default class Camera extends EventEmitter {
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super();
|
|
17
|
-
_defineProperty(this, "transform", void 0);
|
|
18
|
-
// public requestRenderFrame: (_: any) => number;
|
|
19
|
-
// public cancelRenderFrame: (_: number) => void;
|
|
20
|
-
_defineProperty(this, "options", void 0);
|
|
21
|
-
_defineProperty(this, "moving", void 0);
|
|
22
|
-
_defineProperty(this, "zooming", void 0);
|
|
23
|
-
_defineProperty(this, "rotating", void 0);
|
|
24
|
-
_defineProperty(this, "pitching", void 0);
|
|
25
|
-
_defineProperty(this, "padding", void 0);
|
|
26
|
-
_defineProperty(this, "bearingSnap", void 0);
|
|
27
|
-
_defineProperty(this, "easeEndTimeoutID", void 0);
|
|
28
|
-
_defineProperty(this, "easeStart", void 0);
|
|
29
|
-
_defineProperty(this, "easeOptions", void 0);
|
|
30
|
-
_defineProperty(this, "easeId", void 0);
|
|
31
|
-
_defineProperty(this, "onEaseFrame", void 0);
|
|
32
|
-
_defineProperty(this, "onEaseEnd", void 0);
|
|
33
|
-
_defineProperty(this, "easeFrameId", void 0);
|
|
34
|
-
_defineProperty(this, "pitchEnabled", void 0);
|
|
35
|
-
_defineProperty(this, "rotateEnabled", void 0);
|
|
36
|
-
_defineProperty(this, "renderFrameCallback", () => {
|
|
37
|
-
const t = Math.min((now() - this.easeStart) / this.easeOptions.duration, 1);
|
|
38
|
-
this.onEaseFrame(this.easeOptions.easing(t));
|
|
39
|
-
if (t < 1) {
|
|
40
|
-
// this.easeFrameId = window.requestAnimationFrame(this.renderFrameCallback);
|
|
41
|
-
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
42
|
-
} else {
|
|
43
|
-
this.stop();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.options = options;
|
|
47
|
-
const {
|
|
48
|
-
minZoom,
|
|
49
|
-
maxZoom,
|
|
50
|
-
minPitch,
|
|
51
|
-
maxPitch,
|
|
52
|
-
renderWorldCopies
|
|
53
|
-
} = options;
|
|
54
|
-
this.moving = false;
|
|
55
|
-
this.zooming = false;
|
|
56
|
-
this.bearingSnap = options.bearingSnap;
|
|
57
|
-
this.pitchEnabled = options.pitchEnabled;
|
|
58
|
-
this.rotateEnabled = options.rotateEnabled;
|
|
59
|
-
this.transform = new Transform(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
|
|
60
|
-
}
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
requestRenderFrame(cb) {
|
|
63
|
-
return 0;
|
|
64
|
-
}
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
-
cancelRenderFrame(_) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
getCenter() {
|
|
70
|
-
const {
|
|
71
|
-
lng,
|
|
72
|
-
lat
|
|
73
|
-
} = this.transform.center;
|
|
74
|
-
return new LngLat(lng, lat);
|
|
75
|
-
}
|
|
76
|
-
getZoom() {
|
|
77
|
-
return this.transform.zoom;
|
|
78
|
-
}
|
|
79
|
-
getPitch() {
|
|
80
|
-
return this.transform.pitch;
|
|
81
|
-
}
|
|
82
|
-
setCenter(center, eventData) {
|
|
83
|
-
return this.jumpTo({
|
|
84
|
-
center
|
|
85
|
-
}, eventData);
|
|
86
|
-
}
|
|
87
|
-
setPitch(pitch, eventData) {
|
|
88
|
-
this.jumpTo({
|
|
89
|
-
pitch
|
|
90
|
-
}, eventData);
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
getBearing() {
|
|
94
|
-
return this.transform.bearing;
|
|
95
|
-
}
|
|
96
|
-
panTo(lnglat, options, eventData) {
|
|
97
|
-
return this.easeTo(merge({
|
|
98
|
-
center: lnglat
|
|
99
|
-
}, options), eventData);
|
|
100
|
-
}
|
|
101
|
-
panBy(offset, options, eventData) {
|
|
102
|
-
offset = Point.convert(offset).mult(-1);
|
|
103
|
-
return this.panTo(this.transform.center, extend({
|
|
104
|
-
offset
|
|
105
|
-
}, options || {}), eventData);
|
|
106
|
-
}
|
|
107
|
-
zoomOut(options, eventData) {
|
|
108
|
-
this.zoomTo(this.getZoom() - 1, options, eventData);
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
setBearing(bearing, eventData) {
|
|
112
|
-
this.jumpTo({
|
|
113
|
-
bearing
|
|
114
|
-
}, eventData);
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
setZoom(zoom, eventData) {
|
|
118
|
-
this.jumpTo({
|
|
119
|
-
zoom
|
|
120
|
-
}, eventData);
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
zoomIn(options, eventData) {
|
|
124
|
-
this.zoomTo(this.getZoom() + 1, options, eventData);
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
zoomTo(zoom, options, eventData) {
|
|
128
|
-
return this.easeTo(merge({
|
|
129
|
-
zoom
|
|
130
|
-
}, options), eventData);
|
|
131
|
-
}
|
|
132
|
-
getPadding() {
|
|
133
|
-
return this.transform.padding;
|
|
134
|
-
}
|
|
135
|
-
setPadding(padding, eventData) {
|
|
136
|
-
this.jumpTo({
|
|
137
|
-
padding
|
|
138
|
-
}, eventData);
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
rotateTo(bearing, options, eventData) {
|
|
142
|
-
return this.easeTo(merge({
|
|
143
|
-
bearing
|
|
144
|
-
}, options), eventData);
|
|
145
|
-
}
|
|
146
|
-
resetNorth(options, eventData) {
|
|
147
|
-
this.rotateTo(0, merge({
|
|
148
|
-
duration: 1000
|
|
149
|
-
}, options), eventData);
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
resetNorthPitch(options, eventData) {
|
|
153
|
-
this.easeTo(merge({
|
|
154
|
-
bearing: 0,
|
|
155
|
-
pitch: 0,
|
|
156
|
-
duration: 1000
|
|
157
|
-
}, options), eventData);
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
fitBounds(bounds, options, eventData) {
|
|
161
|
-
return this.fitInternal(
|
|
162
|
-
// @ts-ignore
|
|
163
|
-
this.cameraForBounds(bounds, options), options, eventData);
|
|
164
|
-
}
|
|
165
|
-
cameraForBounds(bounds, options) {
|
|
166
|
-
bounds = LngLatBounds.convert(bounds);
|
|
167
|
-
return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0,
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
options);
|
|
170
|
-
}
|
|
171
|
-
snapToNorth(options, eventData) {
|
|
172
|
-
if (Math.abs(this.getBearing()) < this.bearingSnap) {
|
|
173
|
-
return this.resetNorth(options, eventData);
|
|
174
|
-
}
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
jumpTo(options = {}, eventData) {
|
|
178
|
-
this.stop();
|
|
179
|
-
const tr = this.transform;
|
|
180
|
-
let zoomChanged = false;
|
|
181
|
-
let bearingChanged = false;
|
|
182
|
-
let pitchChanged = false;
|
|
183
|
-
if (options.zoom !== undefined && tr.zoom !== +options.zoom) {
|
|
184
|
-
zoomChanged = true;
|
|
185
|
-
tr.zoom = +options.zoom;
|
|
186
|
-
}
|
|
187
|
-
if (options.center !== undefined) {
|
|
188
|
-
tr.center = LngLat.convert(options.center);
|
|
189
|
-
}
|
|
190
|
-
if (options.bearing !== undefined && tr.bearing !== +options.bearing) {
|
|
191
|
-
bearingChanged = true;
|
|
192
|
-
tr.bearing = +options.bearing;
|
|
193
|
-
}
|
|
194
|
-
if (options.pitch !== undefined && tr.pitch !== +options.pitch) {
|
|
195
|
-
pitchChanged = true;
|
|
196
|
-
tr.pitch = +options.pitch;
|
|
197
|
-
}
|
|
198
|
-
if (options.padding !== undefined && !tr.isPaddingEqual(options.padding)) {
|
|
199
|
-
tr.padding = options.padding;
|
|
200
|
-
}
|
|
201
|
-
this.emit('movestart', new Event('movestart', eventData));
|
|
202
|
-
this.emit('move', new Event('move', eventData));
|
|
203
|
-
if (zoomChanged) {
|
|
204
|
-
this.emit('zoomstart', new Event('zoomstart', eventData));
|
|
205
|
-
this.emit('zoom', new Event('zoom', eventData));
|
|
206
|
-
this.emit('zoomend', new Event('zoomend', eventData));
|
|
207
|
-
}
|
|
208
|
-
if (bearingChanged) {
|
|
209
|
-
this.emit('rotatestart', new Event('rotatestart', eventData));
|
|
210
|
-
this.emit('rotate', new Event('rotate', eventData));
|
|
211
|
-
this.emit('rotateend', new Event('rotateend', eventData));
|
|
212
|
-
}
|
|
213
|
-
if (pitchChanged) {
|
|
214
|
-
this.emit('pitchstart', new Event('pitchstart', eventData));
|
|
215
|
-
this.emit('pitch', new Event('pitch', eventData));
|
|
216
|
-
this.emit('pitchend', new Event('pitchend', eventData));
|
|
217
|
-
}
|
|
218
|
-
return this.emit('moveend', new Event('moveend', eventData));
|
|
219
|
-
}
|
|
220
|
-
easeTo(options = {}, eventData) {
|
|
221
|
-
options = merge({
|
|
222
|
-
offset: [0, 0],
|
|
223
|
-
duration: 500,
|
|
224
|
-
easing: defaultEasing
|
|
225
|
-
}, options);
|
|
226
|
-
if (options.animate === false || !options.essential && prefersReducedMotion()) {
|
|
227
|
-
options.duration = 0;
|
|
228
|
-
}
|
|
229
|
-
const tr = this.transform;
|
|
230
|
-
const startZoom = this.getZoom();
|
|
231
|
-
const startBearing = this.getBearing();
|
|
232
|
-
const startPitch = this.getPitch();
|
|
233
|
-
const startPadding = this.getPadding();
|
|
234
|
-
const zoom = options.zoom ? +options.zoom : startZoom;
|
|
235
|
-
const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
236
|
-
const pitch = options.pitch ? +options.pitch : startPitch;
|
|
237
|
-
const padding = options.padding ? options.padding : tr.padding;
|
|
238
|
-
const offsetAsPoint = Point.convert(options.offset);
|
|
239
|
-
let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
240
|
-
const locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
241
|
-
const center = LngLat.convert(options.center || locationAtOffset);
|
|
242
|
-
this.normalizeCenter(center);
|
|
243
|
-
const from = tr.project(locationAtOffset);
|
|
244
|
-
const delta = tr.project(center).sub(from);
|
|
245
|
-
const finalScale = tr.zoomScale(zoom - startZoom);
|
|
246
|
-
let around;
|
|
247
|
-
let aroundPoint;
|
|
248
|
-
if (options.around) {
|
|
249
|
-
around = LngLat.convert(options.around);
|
|
250
|
-
aroundPoint = tr.locationPoint(around);
|
|
251
|
-
}
|
|
252
|
-
const currently = {
|
|
253
|
-
moving: this.moving,
|
|
254
|
-
zooming: this.zooming,
|
|
255
|
-
rotating: this.rotating,
|
|
256
|
-
pitching: this.pitching
|
|
257
|
-
};
|
|
258
|
-
this.zooming = this.zooming || zoom !== startZoom;
|
|
259
|
-
this.rotating = this.rotating || startBearing !== bearing;
|
|
260
|
-
this.pitching = this.pitching || pitch !== startPitch;
|
|
261
|
-
this.padding = !tr.isPaddingEqual(padding);
|
|
262
|
-
this.easeId = options.easeId;
|
|
263
|
-
this.prepareEase(eventData, options.noMoveStart, currently);
|
|
264
|
-
clearTimeout(this.easeEndTimeoutID);
|
|
265
|
-
this.ease(k => {
|
|
266
|
-
if (this.zooming) {
|
|
267
|
-
tr.zoom = interpolate(startZoom, zoom, k);
|
|
268
|
-
}
|
|
269
|
-
if (this.rotating && this.rotateEnabled) {
|
|
270
|
-
tr.bearing = interpolate(startBearing, bearing, k);
|
|
271
|
-
}
|
|
272
|
-
if (this.pitching && this.pitchEnabled) {
|
|
273
|
-
tr.pitch = interpolate(startPitch, pitch, k);
|
|
274
|
-
}
|
|
275
|
-
if (this.padding) {
|
|
276
|
-
tr.interpolatePadding(startPadding, padding, k);
|
|
277
|
-
// When padding is being applied, Transform#centerPoint is changing continously,
|
|
278
|
-
// thus we need to recalculate offsetPoint every fra,e
|
|
279
|
-
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
280
|
-
}
|
|
281
|
-
if (around) {
|
|
282
|
-
tr.setLocationAtPoint(around, aroundPoint);
|
|
283
|
-
} else {
|
|
284
|
-
const scale = tr.zoomScale(tr.zoom - startZoom);
|
|
285
|
-
const base = zoom > startZoom ? Math.min(2, finalScale) : Math.max(0.5, finalScale);
|
|
286
|
-
const speedup = Math.pow(base, 1 - k);
|
|
287
|
-
const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
|
|
288
|
-
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
289
|
-
}
|
|
290
|
-
this.fireMoveEvents(eventData);
|
|
291
|
-
}, interruptingEaseId => {
|
|
292
|
-
this.afterEase(eventData, interruptingEaseId);
|
|
293
|
-
},
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
options);
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
flyTo(options = {}, eventData) {
|
|
299
|
-
// Fall through to jumpTo if user has set prefers-reduced-motion
|
|
300
|
-
if (!options.essential && prefersReducedMotion()) {
|
|
301
|
-
const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']);
|
|
302
|
-
return this.jumpTo(coercedOptions, eventData);
|
|
303
|
-
}
|
|
304
|
-
this.stop();
|
|
305
|
-
options = merge({
|
|
306
|
-
offset: [0, 0],
|
|
307
|
-
speed: 1.2,
|
|
308
|
-
curve: 1.42,
|
|
309
|
-
easing: defaultEasing
|
|
310
|
-
}, options);
|
|
311
|
-
const tr = this.transform;
|
|
312
|
-
const startZoom = this.getZoom();
|
|
313
|
-
const startBearing = this.getBearing();
|
|
314
|
-
const startPitch = this.getPitch();
|
|
315
|
-
const startPadding = this.getPadding();
|
|
316
|
-
const zoom = options.zoom ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;
|
|
317
|
-
const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
318
|
-
const pitch = options.pitch ? +options.pitch : startPitch;
|
|
319
|
-
const padding = 'padding' in options ? options.padding : tr.padding;
|
|
320
|
-
const scale = tr.zoomScale(zoom - startZoom);
|
|
321
|
-
const offsetAsPoint = Point.convert(options.offset);
|
|
322
|
-
let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
323
|
-
const locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
324
|
-
const center = LngLat.convert(options.center || locationAtOffset);
|
|
325
|
-
this.normalizeCenter(center);
|
|
326
|
-
const from = tr.project(locationAtOffset);
|
|
327
|
-
const delta = tr.project(center).sub(from);
|
|
328
|
-
let rho = options.curve;
|
|
329
|
-
|
|
330
|
-
// w₀: Initial visible span, measured in pixels at the initial scale.
|
|
331
|
-
const w0 = Math.max(tr.width, tr.height);
|
|
332
|
-
// w₁: Final visible span, measured in pixels with respect to the initial scale.
|
|
333
|
-
const w1 = w0 / scale;
|
|
334
|
-
// Length of the flight path as projected onto the ground plane, measured in pixels from
|
|
335
|
-
// the world image origin at the initial scale.
|
|
336
|
-
const u1 = delta.mag();
|
|
337
|
-
if ('minZoom' in options) {
|
|
338
|
-
const minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);
|
|
339
|
-
// w<sub>m</sub>: Maximum visible span, measured in pixels with respect to the initial
|
|
340
|
-
// scale.
|
|
341
|
-
const wMax = w0 / tr.zoomScale(minZoom - startZoom);
|
|
342
|
-
rho = Math.sqrt(wMax / u1 * 2);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// ρ²
|
|
346
|
-
const rho2 = rho * rho;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* rᵢ: Returns the zoom-out factor at one end of the animation.
|
|
350
|
-
*
|
|
351
|
-
* @param i 0 for the ascent or 1 for the descent.
|
|
352
|
-
* @private
|
|
353
|
-
*/
|
|
354
|
-
function r(i) {
|
|
355
|
-
const b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
|
|
356
|
-
return Math.log(Math.sqrt(b * b + 1) - b);
|
|
357
|
-
}
|
|
358
|
-
function sinh(n) {
|
|
359
|
-
return (Math.exp(n) - Math.exp(-n)) / 2;
|
|
360
|
-
}
|
|
361
|
-
function cosh(n) {
|
|
362
|
-
return (Math.exp(n) + Math.exp(-n)) / 2;
|
|
363
|
-
}
|
|
364
|
-
function tanh(n) {
|
|
365
|
-
return sinh(n) / cosh(n);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// r₀: Zoom-out factor during ascent.
|
|
369
|
-
const r0 = r(0);
|
|
370
|
-
|
|
371
|
-
// w(s): Returns the visible span on the ground, measured in pixels with respect to the
|
|
372
|
-
// initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.
|
|
373
|
-
let w = s => {
|
|
374
|
-
return cosh(r0) / cosh(r0 + rho * s);
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// u(s): Returns the distance along the flight path as projected onto the ground plane,
|
|
378
|
-
// measured in pixels from the world image origin at the initial scale.
|
|
379
|
-
let u = s => {
|
|
380
|
-
return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
// S: Total length of the flight path, measured in ρ-screenfuls.
|
|
384
|
-
let S = (r(1) - r0) / rho;
|
|
385
|
-
|
|
386
|
-
// When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
|
|
387
|
-
if (Math.abs(u1) < 0.000001 || !isFinite(S)) {
|
|
388
|
-
// Perform a more or less instantaneous transition if the path is too short.
|
|
389
|
-
if (Math.abs(w0 - w1) < 0.000001) {
|
|
390
|
-
return this.easeTo(options, eventData);
|
|
391
|
-
}
|
|
392
|
-
const k = w1 < w0 ? -1 : 1;
|
|
393
|
-
S = Math.abs(Math.log(w1 / w0)) / rho;
|
|
394
|
-
u = () => {
|
|
395
|
-
return 0;
|
|
396
|
-
};
|
|
397
|
-
w = s => {
|
|
398
|
-
return Math.exp(k * rho * s);
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
if ('duration' in options) {
|
|
402
|
-
options.duration = +options.duration;
|
|
403
|
-
} else {
|
|
404
|
-
const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;
|
|
405
|
-
options.duration = 1000 * S / V;
|
|
406
|
-
}
|
|
407
|
-
if (options.maxDuration && options.duration > options.maxDuration) {
|
|
408
|
-
options.duration = 0;
|
|
409
|
-
}
|
|
410
|
-
this.zooming = true;
|
|
411
|
-
this.rotating = startBearing !== bearing;
|
|
412
|
-
this.pitching = pitch !== startPitch;
|
|
413
|
-
this.padding = !tr.isPaddingEqual(padding);
|
|
414
|
-
this.prepareEase(eventData, false);
|
|
415
|
-
this.ease(k => {
|
|
416
|
-
// s: The distance traveled along the flight path, measured in ρ-screenfuls.
|
|
417
|
-
const s = k * S;
|
|
418
|
-
// @ts-ignore
|
|
419
|
-
const easeScale = 1 / w(s);
|
|
420
|
-
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(easeScale);
|
|
421
|
-
if (this.rotating) {
|
|
422
|
-
tr.bearing = interpolate(startBearing, bearing, k);
|
|
423
|
-
}
|
|
424
|
-
if (this.pitching) {
|
|
425
|
-
tr.pitch = interpolate(startPitch, pitch, k);
|
|
426
|
-
}
|
|
427
|
-
if (this.padding) {
|
|
428
|
-
tr.interpolatePadding(startPadding, padding, k);
|
|
429
|
-
// When padding is being applied, Transform#centerPoint is changing continously,
|
|
430
|
-
// thus we need to recalculate offsetPoint every frame
|
|
431
|
-
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
432
|
-
}
|
|
433
|
-
const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(easeScale));
|
|
434
|
-
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
435
|
-
this.fireMoveEvents(eventData);
|
|
436
|
-
}, () => this.afterEase(eventData), options);
|
|
437
|
-
return this;
|
|
438
|
-
}
|
|
439
|
-
fitScreenCoordinates(p0, p1, bearing, options, eventData) {
|
|
440
|
-
return this.fitInternal(
|
|
441
|
-
// @ts-ignore
|
|
442
|
-
this.cameraForBoxAndBearing(this.transform.pointLocation(Point.convert(p0)), this.transform.pointLocation(Point.convert(p1)), bearing,
|
|
443
|
-
// @ts-ignore
|
|
444
|
-
options), options, eventData);
|
|
445
|
-
}
|
|
446
|
-
stop(allowGestures, easeId) {
|
|
447
|
-
if (this.easeFrameId) {
|
|
448
|
-
this.cancelRenderFrame(this.easeFrameId);
|
|
449
|
-
// @ts-ignore
|
|
450
|
-
delete this.easeFrameId;
|
|
451
|
-
// @ts-ignore
|
|
452
|
-
delete this.onEaseFrame;
|
|
453
|
-
}
|
|
454
|
-
if (this.onEaseEnd) {
|
|
455
|
-
// The _onEaseEnd function might emit events which trigger new
|
|
456
|
-
// animation, which sets a new _onEaseEnd. Ensure we don't delete
|
|
457
|
-
// it unintentionally.
|
|
458
|
-
const onEaseEnd = this.onEaseEnd;
|
|
459
|
-
// @ts-ignore
|
|
460
|
-
delete this.onEaseEnd;
|
|
461
|
-
onEaseEnd.call(this, easeId);
|
|
462
|
-
}
|
|
463
|
-
// if (!allowGestures) {
|
|
464
|
-
// const handlers = (this: any).handlers;
|
|
465
|
-
// if (handlers) handlers.stop();
|
|
466
|
-
// }
|
|
467
|
-
return this;
|
|
468
|
-
}
|
|
469
|
-
normalizeBearing(bearing, currentBearing) {
|
|
470
|
-
bearing = wrap(bearing, -180, 180);
|
|
471
|
-
const diff = Math.abs(bearing - currentBearing);
|
|
472
|
-
if (Math.abs(bearing - 360 - currentBearing) < diff) {
|
|
473
|
-
bearing -= 360;
|
|
474
|
-
}
|
|
475
|
-
if (Math.abs(bearing + 360 - currentBearing) < diff) {
|
|
476
|
-
bearing += 360;
|
|
477
|
-
}
|
|
478
|
-
return bearing;
|
|
479
|
-
}
|
|
480
|
-
normalizeCenter(center) {
|
|
481
|
-
const tr = this.transform;
|
|
482
|
-
if (!tr.renderWorldCopies || tr.lngRange) {
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
const delta = center.lng - tr.center.lng;
|
|
486
|
-
center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
|
|
487
|
-
}
|
|
488
|
-
fireMoveEvents(eventData) {
|
|
489
|
-
this.emit('move', new Event('move', eventData));
|
|
490
|
-
if (this.zooming) {
|
|
491
|
-
this.emit('zoom', new Event('zoom', eventData));
|
|
492
|
-
}
|
|
493
|
-
if (this.rotating) {
|
|
494
|
-
this.emit('rotate', new Event('rotate', eventData));
|
|
495
|
-
}
|
|
496
|
-
if (this.pitching) {
|
|
497
|
-
this.emit('rotate', new Event('pitch', eventData));
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
prepareEase(eventData, noMoveStart = false, currently = {}) {
|
|
501
|
-
this.moving = true;
|
|
502
|
-
if (!noMoveStart && !currently.moving) {
|
|
503
|
-
this.emit('movestart', new Event('movestart', eventData));
|
|
504
|
-
}
|
|
505
|
-
if (this.zooming && !currently.zooming) {
|
|
506
|
-
this.emit('zoomstart', new Event('zoomstart', eventData));
|
|
507
|
-
}
|
|
508
|
-
if (this.rotating && !currently.rotating) {
|
|
509
|
-
this.emit('rotatestart', new Event('rotatestart', eventData));
|
|
510
|
-
}
|
|
511
|
-
if (this.pitching && !currently.pitching) {
|
|
512
|
-
this.emit('pitchstart', new Event('pitchstart', eventData));
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
afterEase(eventData, easeId) {
|
|
516
|
-
// if this easing is being stopped to start another easing with
|
|
517
|
-
// the same id then don't fire any events to avoid extra start/stop events
|
|
518
|
-
if (this.easeId && easeId && this.easeId === easeId) {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
// @ts-ignore
|
|
522
|
-
delete this.easeId;
|
|
523
|
-
const wasZooming = this.zooming;
|
|
524
|
-
const wasRotating = this.rotating;
|
|
525
|
-
const wasPitching = this.pitching;
|
|
526
|
-
this.moving = false;
|
|
527
|
-
this.zooming = false;
|
|
528
|
-
this.rotating = false;
|
|
529
|
-
this.pitching = false;
|
|
530
|
-
this.padding = false;
|
|
531
|
-
if (wasZooming) {
|
|
532
|
-
this.emit('zoomend', new Event('zoomend', eventData));
|
|
533
|
-
}
|
|
534
|
-
if (wasRotating) {
|
|
535
|
-
this.emit('rotateend', new Event('rotateend', eventData));
|
|
536
|
-
}
|
|
537
|
-
if (wasPitching) {
|
|
538
|
-
this.emit('pitchend', new Event('pitchend', eventData));
|
|
539
|
-
}
|
|
540
|
-
this.emit('moveend', new Event('moveend', eventData));
|
|
541
|
-
}
|
|
542
|
-
ease(frame, finish, options) {
|
|
543
|
-
if (options.animate === false || options.duration === 0) {
|
|
544
|
-
frame(1);
|
|
545
|
-
finish();
|
|
546
|
-
} else {
|
|
547
|
-
this.easeStart = now();
|
|
548
|
-
this.easeOptions = options;
|
|
549
|
-
this.onEaseFrame = frame;
|
|
550
|
-
this.onEaseEnd = finish;
|
|
551
|
-
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
cameraForBoxAndBearing(p0, p1, bearing, options) {
|
|
555
|
-
const defaultPadding = {
|
|
556
|
-
top: 0,
|
|
557
|
-
bottom: 0,
|
|
558
|
-
right: 0,
|
|
559
|
-
left: 0
|
|
560
|
-
};
|
|
561
|
-
options = merge({
|
|
562
|
-
padding: defaultPadding,
|
|
563
|
-
offset: [0, 0],
|
|
564
|
-
maxZoom: this.transform.maxZoom
|
|
565
|
-
}, options);
|
|
566
|
-
if (typeof options.padding === 'number') {
|
|
567
|
-
const p = options.padding;
|
|
568
|
-
options.padding = {
|
|
569
|
-
top: p,
|
|
570
|
-
bottom: p,
|
|
571
|
-
right: p,
|
|
572
|
-
left: p
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
options.padding = merge(defaultPadding, options.padding);
|
|
576
|
-
const tr = this.transform;
|
|
577
|
-
const edgePadding = tr.padding;
|
|
578
|
-
|
|
579
|
-
// We want to calculate the upper right and lower left of the box defined by p0 and p1
|
|
580
|
-
// in a coordinate system rotate to match the destination bearing.
|
|
581
|
-
const p0world = tr.project(LngLat.convert(p0));
|
|
582
|
-
const p1world = tr.project(LngLat.convert(p1));
|
|
583
|
-
const p0rotated = p0world.rotate(-bearing * Math.PI / 180);
|
|
584
|
-
const p1rotated = p1world.rotate(-bearing * Math.PI / 180);
|
|
585
|
-
const upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));
|
|
586
|
-
const lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));
|
|
587
|
-
|
|
588
|
-
// Calculate zoom: consider the original bbox and padding.
|
|
589
|
-
const size = upperRight.sub(lowerLeft);
|
|
590
|
-
const scaleX = (tr.width - (
|
|
591
|
-
// @ts-ignore
|
|
592
|
-
edgePadding.left +
|
|
593
|
-
// @ts-ignore
|
|
594
|
-
edgePadding.right +
|
|
595
|
-
// @ts-ignore
|
|
596
|
-
options.padding.left +
|
|
597
|
-
// @ts-ignore
|
|
598
|
-
options.padding.right)) / size.x;
|
|
599
|
-
const scaleY = (tr.height - (
|
|
600
|
-
// @ts-ignore
|
|
601
|
-
edgePadding.top +
|
|
602
|
-
// @ts-ignore
|
|
603
|
-
edgePadding.bottom +
|
|
604
|
-
// @ts-ignore
|
|
605
|
-
options.padding.top +
|
|
606
|
-
// @ts-ignore
|
|
607
|
-
options.padding.bottom)) / size.y;
|
|
608
|
-
if (scaleY < 0 || scaleX < 0) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
|
|
612
|
-
|
|
613
|
-
// Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.
|
|
614
|
-
const offset = Point.convert(options.offset);
|
|
615
|
-
// @ts-ignore
|
|
616
|
-
const paddingOffsetX = (options.padding.left - options.padding.right) / 2;
|
|
617
|
-
// @ts-ignore
|
|
618
|
-
const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;
|
|
619
|
-
const offsetAtInitialZoom = new Point(offset.x + paddingOffsetX, offset.y + paddingOffsetY);
|
|
620
|
-
const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));
|
|
621
|
-
const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));
|
|
622
|
-
return {
|
|
623
|
-
center,
|
|
624
|
-
zoom,
|
|
625
|
-
bearing
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
fitInternal(calculatedOptions, options, eventData) {
|
|
629
|
-
// cameraForBounds warns + returns undefined if unable to fit:
|
|
630
|
-
if (!calculatedOptions) {
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
options = merge(calculatedOptions, options);
|
|
634
|
-
// Explictly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.
|
|
635
|
-
delete options.padding;
|
|
636
|
-
// @ts-ignore
|
|
637
|
-
return options.linear ? this.easeTo(options, eventData) : this.flyTo(options, eventData);
|
|
638
|
-
}
|
|
639
|
-
}
|
package/es/earthmap.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import Camera from './camera';
|
|
2
|
-
import './css/l7.css';
|
|
3
|
-
import type { LngLatLike } from './geo/lng_lat';
|
|
4
|
-
import LngLat from './geo/lng_lat';
|
|
5
|
-
import type { LngLatBoundsLike } from './geo/lng_lat_bounds';
|
|
6
|
-
import LngLatBounds from './geo/lng_lat_bounds';
|
|
7
|
-
import type { PointLike } from './geo/point';
|
|
8
|
-
import Point from './geo/point';
|
|
9
|
-
import type BoxZoomHandler from './handler/box_zoom';
|
|
10
|
-
import HandlerManager from './handler/handler_manager';
|
|
11
|
-
import type KeyboardHandler from './handler/keyboard';
|
|
12
|
-
import type ScrollZoomHandler from './handler/scroll_zoom';
|
|
13
|
-
import type DoubleClickZoomHandler from './handler/shim/dblclick_zoom';
|
|
14
|
-
import type DragPanHandler from './handler/shim/drag_pan';
|
|
15
|
-
import type DragRotateHandler from './handler/shim/drag_rotate';
|
|
16
|
-
import type TouchZoomRotateHandler from './handler/shim/touch_zoom_rotate';
|
|
17
|
-
import type { TouchPitchHandler } from './handler/touch';
|
|
18
|
-
import type { IMapOptions } from './interface';
|
|
19
|
-
import type { TaskID } from './utils/task_queue';
|
|
20
|
-
type CallBack = (_: number) => void;
|
|
21
|
-
export declare class EarthMap extends Camera {
|
|
22
|
-
doubleClickZoom: DoubleClickZoomHandler;
|
|
23
|
-
dragRotate: DragRotateHandler;
|
|
24
|
-
dragPan: DragPanHandler;
|
|
25
|
-
touchZoomRotate: TouchZoomRotateHandler;
|
|
26
|
-
scrollZoom: ScrollZoomHandler;
|
|
27
|
-
keyboard: KeyboardHandler;
|
|
28
|
-
touchPitch: TouchPitchHandler;
|
|
29
|
-
boxZoom: BoxZoomHandler;
|
|
30
|
-
handlers: HandlerManager;
|
|
31
|
-
private container;
|
|
32
|
-
private canvas;
|
|
33
|
-
private canvasContainer;
|
|
34
|
-
private renderTaskQueue;
|
|
35
|
-
private frame;
|
|
36
|
-
private trackResize;
|
|
37
|
-
constructor(options: Partial<IMapOptions>);
|
|
38
|
-
resize(eventData?: any): this;
|
|
39
|
-
getContainer(): HTMLElement;
|
|
40
|
-
getCanvas(): HTMLCanvasElement;
|
|
41
|
-
getCanvasContainer(): HTMLElement;
|
|
42
|
-
project(lngLat: LngLatLike): Point;
|
|
43
|
-
unproject(point: PointLike): LngLat;
|
|
44
|
-
getBounds(): LngLatBounds;
|
|
45
|
-
getMaxBounds(): LngLatBounds | null;
|
|
46
|
-
setMaxBounds(bounds: LngLatBoundsLike): void;
|
|
47
|
-
setStyle(style: any): void;
|
|
48
|
-
setMinZoom(minZoom?: number): this;
|
|
49
|
-
getMinZoom(): number;
|
|
50
|
-
setMaxZoom(maxZoom?: number): this;
|
|
51
|
-
getMaxZoom(): number;
|
|
52
|
-
setMinPitch(minPitch?: number): this;
|
|
53
|
-
getMinPitch(): number;
|
|
54
|
-
setMaxPitch(maxPitch?: number): this;
|
|
55
|
-
getMaxPitch(): number;
|
|
56
|
-
getRenderWorldCopies(): boolean;
|
|
57
|
-
setRenderWorldCopies(renderWorldCopies?: boolean): void;
|
|
58
|
-
remove(): void;
|
|
59
|
-
requestRenderFrame(cb: CallBack): TaskID;
|
|
60
|
-
cancelRenderFrame(id: TaskID): void;
|
|
61
|
-
triggerRepaint(): void;
|
|
62
|
-
update(time?: number): void;
|
|
63
|
-
private initContainer;
|
|
64
|
-
private containerDimensions;
|
|
65
|
-
private resizeCanvas;
|
|
66
|
-
private onWindowOnline;
|
|
67
|
-
private onWindowResize;
|
|
68
|
-
}
|
|
69
|
-
export {};
|