@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
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _point = _interopRequireDefault(require("../../geo/point"));
|
|
10
|
-
var _handler_util = require("../handler_util");
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
class TouchPanHandler {
|
|
14
|
-
constructor(options) {
|
|
15
|
-
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
16
|
-
(0, _defineProperty2.default)(this, "active", void 0);
|
|
17
|
-
(0, _defineProperty2.default)(this, "touches", void 0);
|
|
18
|
-
(0, _defineProperty2.default)(this, "minTouches", void 0);
|
|
19
|
-
(0, _defineProperty2.default)(this, "clickTolerance", void 0);
|
|
20
|
-
(0, _defineProperty2.default)(this, "sum", void 0);
|
|
21
|
-
this.minTouches = 1;
|
|
22
|
-
this.clickTolerance = options.clickTolerance || 1;
|
|
23
|
-
this.reset();
|
|
24
|
-
}
|
|
25
|
-
reset() {
|
|
26
|
-
this.active = false;
|
|
27
|
-
this.touches = {};
|
|
28
|
-
this.sum = new _point.default(0, 0);
|
|
29
|
-
}
|
|
30
|
-
touchstart(e, points, mapTouches) {
|
|
31
|
-
return this.calculateTransform(e, points, mapTouches);
|
|
32
|
-
}
|
|
33
|
-
touchmove(e, points, mapTouches) {
|
|
34
|
-
if (!this.active) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
return this.calculateTransform(e, points, mapTouches);
|
|
39
|
-
}
|
|
40
|
-
touchend(e, points, mapTouches) {
|
|
41
|
-
this.calculateTransform(e, points, mapTouches);
|
|
42
|
-
if (this.active && mapTouches.length < this.minTouches) {
|
|
43
|
-
this.reset();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
touchcancel() {
|
|
47
|
-
this.reset();
|
|
48
|
-
}
|
|
49
|
-
enable() {
|
|
50
|
-
this.enabled = true;
|
|
51
|
-
}
|
|
52
|
-
disable() {
|
|
53
|
-
this.enabled = false;
|
|
54
|
-
this.reset();
|
|
55
|
-
}
|
|
56
|
-
isEnabled() {
|
|
57
|
-
return this.enabled;
|
|
58
|
-
}
|
|
59
|
-
isActive() {
|
|
60
|
-
return this.active;
|
|
61
|
-
}
|
|
62
|
-
calculateTransform(e, points, mapTouches) {
|
|
63
|
-
if (mapTouches.length > 0) {
|
|
64
|
-
this.active = true;
|
|
65
|
-
}
|
|
66
|
-
const touches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
67
|
-
const touchPointSum = new _point.default(0, 0);
|
|
68
|
-
const touchDeltaSum = new _point.default(0, 0);
|
|
69
|
-
let touchDeltaCount = 0;
|
|
70
|
-
for (const identifier in touches) {
|
|
71
|
-
if (touches[identifier]) {
|
|
72
|
-
const point = touches[identifier];
|
|
73
|
-
const prevPoint = this.touches[identifier];
|
|
74
|
-
if (prevPoint) {
|
|
75
|
-
touchPointSum._add(point);
|
|
76
|
-
touchDeltaSum._add(point.sub(prevPoint));
|
|
77
|
-
touchDeltaCount++;
|
|
78
|
-
touches[identifier] = point;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
this.touches = touches;
|
|
83
|
-
if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
const panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
88
|
-
this.sum._add(panDelta);
|
|
89
|
-
if (this.sum.mag() < this.clickTolerance) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
const around = touchPointSum.div(touchDeltaCount);
|
|
94
|
-
return {
|
|
95
|
-
around,
|
|
96
|
-
panDelta
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.default = TouchPanHandler;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchPitchHandler extends TwoTouchHandler {
|
|
4
|
-
valid: boolean | void;
|
|
5
|
-
firstMove: number;
|
|
6
|
-
lastPoints: [Point, Point];
|
|
7
|
-
reset(): void;
|
|
8
|
-
start(points: [Point, Point]): void;
|
|
9
|
-
move(points: [Point, Point], center: Point, e: TouchEvent): {
|
|
10
|
-
pitchDelta: number;
|
|
11
|
-
} | undefined;
|
|
12
|
-
gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number): boolean | undefined;
|
|
13
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
|
|
12
|
-
function isVertical(vector) {
|
|
13
|
-
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
14
|
-
}
|
|
15
|
-
const ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
16
|
-
class TouchPitchHandler extends _two_touch.default {
|
|
17
|
-
constructor(...args) {
|
|
18
|
-
super(...args);
|
|
19
|
-
(0, _defineProperty2.default)(this, "valid", void 0);
|
|
20
|
-
(0, _defineProperty2.default)(this, "firstMove", void 0);
|
|
21
|
-
(0, _defineProperty2.default)(this, "lastPoints", void 0);
|
|
22
|
-
}
|
|
23
|
-
reset() {
|
|
24
|
-
super.reset();
|
|
25
|
-
this.valid = undefined;
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
delete this.firstMove;
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
delete this.lastPoints;
|
|
30
|
-
}
|
|
31
|
-
start(points) {
|
|
32
|
-
this.lastPoints = points;
|
|
33
|
-
if (isVertical(points[0].sub(points[1]))) {
|
|
34
|
-
// fingers are more horizontal than vertical
|
|
35
|
-
this.valid = false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
move(points, center, e) {
|
|
39
|
-
const vectorA = points[0].sub(this.lastPoints[0]);
|
|
40
|
-
const vectorB = points[1].sub(this.lastPoints[1]);
|
|
41
|
-
this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
42
|
-
if (!this.valid) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
this.lastPoints = points;
|
|
46
|
-
this.active = true;
|
|
47
|
-
const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
48
|
-
const degreesPerPixelMoved = -0.5;
|
|
49
|
-
return {
|
|
50
|
-
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
54
|
-
if (this.valid !== undefined) {
|
|
55
|
-
return this.valid;
|
|
56
|
-
}
|
|
57
|
-
const threshold = 2;
|
|
58
|
-
const movedA = vectorA.mag() >= threshold;
|
|
59
|
-
const movedB = vectorB.mag() >= threshold;
|
|
60
|
-
|
|
61
|
-
// neither finger has moved a meaningful amount, wait
|
|
62
|
-
if (!movedA && !movedB) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// One finger has moved and the other has not.
|
|
67
|
-
// If enough time has passed, decide it is not a pitch.
|
|
68
|
-
if (!movedA || !movedB) {
|
|
69
|
-
if (this.firstMove === undefined) {
|
|
70
|
-
this.firstMove = timeStamp;
|
|
71
|
-
}
|
|
72
|
-
if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
73
|
-
// still waiting for a movement from the second finger
|
|
74
|
-
return undefined;
|
|
75
|
-
} else {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
80
|
-
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.default = TouchPitchHandler;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchRotateHandler extends TwoTouchHandler {
|
|
4
|
-
private minDiameter;
|
|
5
|
-
reset(): void;
|
|
6
|
-
start(points: [Point, Point]): void;
|
|
7
|
-
move(points: [Point, Point], pinchAround: Point): {
|
|
8
|
-
bearingDelta: number;
|
|
9
|
-
pinchAround: Point;
|
|
10
|
-
} | undefined;
|
|
11
|
-
private isBelowThreshold;
|
|
12
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
|
|
12
|
-
const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
13
|
-
|
|
14
|
-
function getBearingDelta(a, b) {
|
|
15
|
-
return a.angleWith(b) * 180 / Math.PI;
|
|
16
|
-
}
|
|
17
|
-
class TouchRotateHandler extends _two_touch.default {
|
|
18
|
-
constructor(...args) {
|
|
19
|
-
super(...args);
|
|
20
|
-
(0, _defineProperty2.default)(this, "minDiameter", void 0);
|
|
21
|
-
}
|
|
22
|
-
reset() {
|
|
23
|
-
super.reset();
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
delete this.minDiameter;
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
delete this.startVector;
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
delete this.vector;
|
|
30
|
-
}
|
|
31
|
-
start(points) {
|
|
32
|
-
this.startVector = this.vector = points[0].sub(points[1]);
|
|
33
|
-
this.minDiameter = points[0].dist(points[1]);
|
|
34
|
-
}
|
|
35
|
-
move(points, pinchAround) {
|
|
36
|
-
const lastVector = this.vector;
|
|
37
|
-
this.vector = points[0].sub(points[1]);
|
|
38
|
-
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.active = true;
|
|
42
|
-
return {
|
|
43
|
-
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
44
|
-
pinchAround
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
isBelowThreshold(vector) {
|
|
48
|
-
/*
|
|
49
|
-
* The threshold before a rotation actually happens is configured in
|
|
50
|
-
* pixels alongth circumference of the circle formed by the two fingers.
|
|
51
|
-
* This makes the threshold in degrees larger when the fingers are close
|
|
52
|
-
* together and smaller when the fingers are far apart.
|
|
53
|
-
*
|
|
54
|
-
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
55
|
-
* when pinching in and out.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
this.minDiameter = Math.min(this.minDiameter, vector.mag());
|
|
59
|
-
const circumference = Math.PI * this.minDiameter;
|
|
60
|
-
const threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
61
|
-
const bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
|
|
62
|
-
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.default = TouchRotateHandler;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchZoomHandler extends TwoTouchHandler {
|
|
4
|
-
private distance;
|
|
5
|
-
private startDistance;
|
|
6
|
-
reset(): void;
|
|
7
|
-
start(points: [Point, Point]): void;
|
|
8
|
-
move(points: [Point, Point], pinchAround: Point): {
|
|
9
|
-
zoomDelta: number;
|
|
10
|
-
pinchAround: Point;
|
|
11
|
-
} | undefined;
|
|
12
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
|
|
12
|
-
const ZOOM_THRESHOLD = 0.1;
|
|
13
|
-
function getZoomDelta(distance, lastDistance) {
|
|
14
|
-
return Math.log(distance / lastDistance) / Math.LN2;
|
|
15
|
-
}
|
|
16
|
-
class TouchZoomHandler extends _two_touch.default {
|
|
17
|
-
constructor(...args) {
|
|
18
|
-
super(...args);
|
|
19
|
-
(0, _defineProperty2.default)(this, "distance", void 0);
|
|
20
|
-
(0, _defineProperty2.default)(this, "startDistance", void 0);
|
|
21
|
-
}
|
|
22
|
-
reset() {
|
|
23
|
-
super.reset();
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
delete this.distance;
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
delete this.startDistance;
|
|
28
|
-
}
|
|
29
|
-
start(points) {
|
|
30
|
-
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
31
|
-
}
|
|
32
|
-
move(points, pinchAround) {
|
|
33
|
-
const lastDistance = this.distance;
|
|
34
|
-
this.distance = points[0].dist(points[1]);
|
|
35
|
-
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.active = true;
|
|
39
|
-
return {
|
|
40
|
-
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
41
|
-
pinchAround
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.default = TouchZoomHandler;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type Point from '../../geo/point';
|
|
2
|
-
export default class TwoTouchHandler {
|
|
3
|
-
protected enabled: boolean;
|
|
4
|
-
protected active: boolean;
|
|
5
|
-
protected firstTwoTouches: [number, number];
|
|
6
|
-
protected vector: Point;
|
|
7
|
-
protected startVector: Point;
|
|
8
|
-
protected aroundCenter: boolean;
|
|
9
|
-
constructor();
|
|
10
|
-
reset(): void;
|
|
11
|
-
start(points: [Point, Point]): void;
|
|
12
|
-
move(points: [Point, Point], pinchAround: Point | null, e: TouchEvent): void;
|
|
13
|
-
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
14
|
-
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
15
|
-
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
16
|
-
touchcancel(): void;
|
|
17
|
-
enable(options?: {
|
|
18
|
-
around?: 'center';
|
|
19
|
-
}): void;
|
|
20
|
-
disable(): void;
|
|
21
|
-
isEnabled(): boolean;
|
|
22
|
-
isActive(): boolean;
|
|
23
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _dom = _interopRequireDefault(require("../../utils/dom"));
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
|
|
12
|
-
class TwoTouchHandler {
|
|
13
|
-
constructor() {
|
|
14
|
-
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
15
|
-
(0, _defineProperty2.default)(this, "active", void 0);
|
|
16
|
-
(0, _defineProperty2.default)(this, "firstTwoTouches", void 0);
|
|
17
|
-
(0, _defineProperty2.default)(this, "vector", void 0);
|
|
18
|
-
(0, _defineProperty2.default)(this, "startVector", void 0);
|
|
19
|
-
(0, _defineProperty2.default)(this, "aroundCenter", void 0);
|
|
20
|
-
this.reset();
|
|
21
|
-
}
|
|
22
|
-
reset() {
|
|
23
|
-
this.active = false;
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
delete this.firstTwoTouches;
|
|
26
|
-
}
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
-
start(points) {
|
|
29
|
-
return;
|
|
30
|
-
} // eslint-disable-line
|
|
31
|
-
move(
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
points,
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
-
pinchAround,
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
e) {
|
|
38
|
-
return;
|
|
39
|
-
} // eslint-disable-line
|
|
40
|
-
|
|
41
|
-
touchstart(e, points, mapTouches) {
|
|
42
|
-
if (this.firstTwoTouches || mapTouches.length < 2) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
46
|
-
|
|
47
|
-
// implemented by child classes
|
|
48
|
-
this.start([points[0], points[1]]);
|
|
49
|
-
}
|
|
50
|
-
touchmove(e, points, mapTouches) {
|
|
51
|
-
if (!this.firstTwoTouches) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
const [idA, idB] = this.firstTwoTouches;
|
|
56
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
57
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
58
|
-
if (!a || !b) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
62
|
-
|
|
63
|
-
// implemented by child classes
|
|
64
|
-
return this.move([a, b], pinchAround, e);
|
|
65
|
-
}
|
|
66
|
-
touchend(e, points, mapTouches) {
|
|
67
|
-
if (!this.firstTwoTouches) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const [idA, idB] = this.firstTwoTouches;
|
|
71
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
72
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
73
|
-
if (a && b) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (this.active) {
|
|
77
|
-
_dom.default.suppressClick();
|
|
78
|
-
}
|
|
79
|
-
this.reset();
|
|
80
|
-
}
|
|
81
|
-
touchcancel() {
|
|
82
|
-
this.reset();
|
|
83
|
-
}
|
|
84
|
-
enable(options) {
|
|
85
|
-
this.enabled = true;
|
|
86
|
-
this.aroundCenter = !!options && options.around === 'center';
|
|
87
|
-
}
|
|
88
|
-
disable() {
|
|
89
|
-
this.enabled = false;
|
|
90
|
-
this.reset();
|
|
91
|
-
}
|
|
92
|
-
isEnabled() {
|
|
93
|
-
return this.enabled;
|
|
94
|
-
}
|
|
95
|
-
isActive() {
|
|
96
|
-
return this.active;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.default = TwoTouchHandler;
|
|
100
|
-
function getTouchById(mapTouches, points, identifier) {
|
|
101
|
-
for (let i = 0; i < mapTouches.length; i++) {
|
|
102
|
-
if (mapTouches[i].identifier === identifier) {
|
|
103
|
-
return points[i];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
package/lib/hash.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Map } from './map';
|
|
2
|
-
declare class Hash {
|
|
3
|
-
private map;
|
|
4
|
-
private updateHash;
|
|
5
|
-
private hashName?;
|
|
6
|
-
constructor(hashName?: string);
|
|
7
|
-
addTo(map: Map): this;
|
|
8
|
-
remove(): this;
|
|
9
|
-
onHashChange: () => boolean;
|
|
10
|
-
private getCurrentHash;
|
|
11
|
-
private getHashString;
|
|
12
|
-
private updateHashUnthrottled;
|
|
13
|
-
}
|
|
14
|
-
export default Hash;
|
package/lib/hash.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
// tslint:disable-next-line:no-submodule-imports
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
throttle
|
|
15
|
-
} = _l7Utils.lodashUtil;
|
|
16
|
-
/*
|
|
17
|
-
* Adds the map's position to its page's location hash.
|
|
18
|
-
* Passed as an option to the map object.
|
|
19
|
-
*
|
|
20
|
-
* @returns {Hash} `this`
|
|
21
|
-
*/
|
|
22
|
-
class Hash {
|
|
23
|
-
constructor(hashName) {
|
|
24
|
-
(0, _defineProperty2.default)(this, "map", void 0);
|
|
25
|
-
(0, _defineProperty2.default)(this, "updateHash", void 0);
|
|
26
|
-
(0, _defineProperty2.default)(this, "hashName", void 0);
|
|
27
|
-
(0, _defineProperty2.default)(this, "onHashChange", () => {
|
|
28
|
-
const loc = this.getCurrentHash();
|
|
29
|
-
if (loc.length >= 3 && !loc.some(v => isNaN(+v))) {
|
|
30
|
-
const bearing = this.map.dragRotate.isEnabled() && this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this.map.getBearing();
|
|
31
|
-
this.map.jumpTo({
|
|
32
|
-
center: [+loc[2], +loc[1]],
|
|
33
|
-
zoom: +loc[0],
|
|
34
|
-
bearing,
|
|
35
|
-
pitch: +(loc[4] || 0)
|
|
36
|
-
});
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
});
|
|
41
|
-
(0, _defineProperty2.default)(this, "getCurrentHash", () => {
|
|
42
|
-
// Get the current hash from location, stripped from its number sign
|
|
43
|
-
const hash = window.location.hash.replace('#', '');
|
|
44
|
-
if (this.hashName) {
|
|
45
|
-
// Split the parameter-styled hash into parts and find the value we need
|
|
46
|
-
let keyval;
|
|
47
|
-
hash.split('&').map(part => part.split('=')).forEach(part => {
|
|
48
|
-
if (part[0] === this.hashName) {
|
|
49
|
-
keyval = part;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return (keyval ? keyval[1] || '' : '').split('/');
|
|
53
|
-
}
|
|
54
|
-
return hash.split('/');
|
|
55
|
-
});
|
|
56
|
-
(0, _defineProperty2.default)(this, "updateHashUnthrottled", () => {
|
|
57
|
-
const hash = this.getHashString();
|
|
58
|
-
try {
|
|
59
|
-
window.history.replaceState(window.history.state, '', hash);
|
|
60
|
-
} catch (SecurityError) {
|
|
61
|
-
// IE11 does not allow this if the page is within an iframe created
|
|
62
|
-
// with iframe.contentWindow.document.write(...).
|
|
63
|
-
// https://github.com/mapbox/mapbox-gl-js/issues/7410
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
this.hashName = hashName && encodeURIComponent(hashName);
|
|
67
|
-
|
|
68
|
-
// Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
|
|
69
|
-
this.updateHash = throttle(this.updateHashUnthrottled, 30 * 1000 / 100);
|
|
70
|
-
}
|
|
71
|
-
addTo(map) {
|
|
72
|
-
this.map = map;
|
|
73
|
-
window.addEventListener('hashchange', this.onHashChange, false);
|
|
74
|
-
this.map.on('moveend', this.updateHash);
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
remove() {
|
|
78
|
-
window.removeEventListener('hashchange', this.onHashChange, false);
|
|
79
|
-
this.map.off('moveend', this.updateHash);
|
|
80
|
-
// clearTimeout(this.updateHash());
|
|
81
|
-
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
delete this.map;
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
getHashString(mapFeedback) {
|
|
87
|
-
const center = this.map.getCenter();
|
|
88
|
-
const zoom = Math.round(this.map.getZoom() * 100) / 100;
|
|
89
|
-
// derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
|
|
90
|
-
const precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
|
|
91
|
-
const m = Math.pow(10, precision);
|
|
92
|
-
const lng = Math.round(center.lng * m) / m;
|
|
93
|
-
const lat = Math.round(center.lat * m) / m;
|
|
94
|
-
const bearing = this.map.getBearing();
|
|
95
|
-
const pitch = this.map.getPitch();
|
|
96
|
-
let hash = '';
|
|
97
|
-
if (mapFeedback) {
|
|
98
|
-
// new map feedback site has some constraints that don't allow
|
|
99
|
-
// us to use the same hash format as we do for the Map hash option.
|
|
100
|
-
hash += `/${lng}/${lat}/${zoom}`;
|
|
101
|
-
} else {
|
|
102
|
-
hash += `${zoom}/${lat}/${lng}`;
|
|
103
|
-
}
|
|
104
|
-
if (bearing || pitch) {
|
|
105
|
-
hash += `/${Math.round(bearing * 10) / 10}`;
|
|
106
|
-
}
|
|
107
|
-
if (pitch) {
|
|
108
|
-
hash += `/${Math.round(pitch)}`;
|
|
109
|
-
}
|
|
110
|
-
if (this.hashName) {
|
|
111
|
-
const hashName = this.hashName;
|
|
112
|
-
let found = false;
|
|
113
|
-
const parts = window.location.hash.slice(1).split('&').map(part => {
|
|
114
|
-
const key = part.split('=')[0];
|
|
115
|
-
if (key === hashName) {
|
|
116
|
-
found = true;
|
|
117
|
-
return `${key}=${hash}`;
|
|
118
|
-
}
|
|
119
|
-
return part;
|
|
120
|
-
}).filter(a => a);
|
|
121
|
-
if (!found) {
|
|
122
|
-
parts.push(`${hashName}=${hash}`);
|
|
123
|
-
}
|
|
124
|
-
return `#${parts.join('&')}`;
|
|
125
|
-
}
|
|
126
|
-
return `#${hash}`;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
var _default = exports.default = Hash;
|
package/lib/interface.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { LngLatBoundsLike } from './geo/lng_lat_bounds';
|
|
2
|
-
export interface IMapOptions {
|
|
3
|
-
hash: boolean;
|
|
4
|
-
style?: any;
|
|
5
|
-
container?: HTMLElement | string;
|
|
6
|
-
canvas?: HTMLCanvasElement;
|
|
7
|
-
center: [number, number];
|
|
8
|
-
zoom: number;
|
|
9
|
-
bearing: number;
|
|
10
|
-
pitch: number;
|
|
11
|
-
interactive: boolean;
|
|
12
|
-
scrollZoom: boolean;
|
|
13
|
-
bounds?: LngLatBoundsLike;
|
|
14
|
-
maxBounds?: LngLatBoundsLike;
|
|
15
|
-
fitBoundsOptions?: any;
|
|
16
|
-
minZoom: number;
|
|
17
|
-
maxZoom: number;
|
|
18
|
-
minPitch: number;
|
|
19
|
-
maxPitch: number;
|
|
20
|
-
boxZoom: boolean;
|
|
21
|
-
dragRotate: boolean;
|
|
22
|
-
dragPan: boolean;
|
|
23
|
-
keyboard: boolean;
|
|
24
|
-
doubleClickZoom: boolean;
|
|
25
|
-
touchZoomRotate: boolean;
|
|
26
|
-
touchPitch: boolean;
|
|
27
|
-
trackResize: boolean;
|
|
28
|
-
renderWorldCopies: boolean;
|
|
29
|
-
bearingSnap: number;
|
|
30
|
-
clickTolerance: number;
|
|
31
|
-
pitchWithRotate: boolean;
|
|
32
|
-
pitchEnabled: boolean;
|
|
33
|
-
rotateEnabled: boolean;
|
|
34
|
-
}
|