@antv/l7-map 2.9.20 → 2.9.22
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/es/camera.js +115 -85
- package/es/css/l7.css +98 -0
- package/es/earthmap.js +27 -43
- package/es/geo/edge_insets.js +44 -14
- package/es/geo/lng_lat.js +15 -11
- package/es/geo/lng_lat_bounds.js +6 -10
- package/es/geo/mercator.js +24 -12
- package/es/geo/point.js +2 -8
- package/es/geo/simple.js +24 -12
- package/es/geo/transform.js +421 -120
- package/es/handler/IHandler.js +1 -2
- package/es/handler/blockable_map_event.js +13 -14
- package/es/handler/box_zoom.js +43 -27
- package/es/handler/click_zoom.js +3 -8
- package/es/handler/events/event.js +3 -6
- package/es/handler/events/index.js +4 -5
- package/es/handler/events/map_mouse_event.js +30 -20
- package/es/handler/events/map_touch_event.js +55 -25
- package/es/handler/events/map_wheel_event.js +24 -15
- package/es/handler/events/render_event.js +3 -6
- package/es/handler/handler_inertia.js +10 -12
- package/es/handler/handler_manager.js +75 -72
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +20 -15
- package/es/handler/map_event.js +23 -12
- package/es/handler/mouse/index.js +4 -5
- package/es/handler/mouse/mouse_handler.js +17 -21
- package/es/handler/mouse/mousepan_handler.js +5 -5
- package/es/handler/mouse/mousepitch_hander.js +7 -5
- package/es/handler/mouse/mouserotate_hander.js +7 -5
- package/es/handler/mouse/util.js +3 -3
- package/es/handler/scroll_zoom.js +103 -67
- package/es/handler/shim/dblclick_zoom.js +35 -8
- package/es/handler/shim/drag_pan.js +48 -12
- package/es/handler/shim/drag_rotate.js +39 -10
- package/es/handler/shim/touch_zoom_rotate.js +59 -16
- package/es/handler/tap/single_tap_recognizer.js +7 -17
- package/es/handler/tap/tap_drag_zoom.js +5 -18
- package/es/handler/tap/tap_recognizer.js +4 -15
- package/es/handler/tap/tap_zoom.js +4 -13
- package/es/handler/touch/index.js +5 -6
- package/es/handler/touch/touch_pan.js +9 -20
- package/es/handler/touch/touch_pitch.js +11 -23
- package/es/handler/touch/touch_rotate.js +15 -18
- package/es/handler/touch/touch_zoom.js +5 -19
- package/es/handler/touch/two_touch.js +14 -21
- package/es/hash.js +28 -16
- package/es/index.js +2 -3
- package/es/interface.js +1 -2
- package/es/map.js +26 -47
- package/es/util.js +15 -6
- package/es/utils/Aabb.js +11 -12
- package/es/utils/dom.js +30 -11
- package/es/utils/performance.js +10 -6
- package/es/utils/primitives.js +11 -10
- package/es/utils/task_queue.js +6 -13
- package/lib/camera.js +508 -721
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +222 -392
- package/lib/geo/edge_insets.js +64 -83
- package/lib/geo/lng_lat.js +65 -81
- package/lib/geo/lng_lat_bounds.js +124 -165
- package/lib/geo/mercator.js +62 -78
- package/lib/geo/point.js +171 -239
- package/lib/geo/simple.js +61 -80
- package/lib/geo/transform.js +470 -653
- package/lib/handler/IHandler.js +17 -2
- package/lib/handler/blockable_map_event.js +63 -83
- package/lib/handler/box_zoom.js +123 -176
- package/lib/handler/click_zoom.js +56 -68
- package/lib/handler/events/event.js +35 -23
- package/lib/handler/events/index.js +35 -29
- package/lib/handler/events/map_mouse_event.js +42 -72
- package/lib/handler/events/map_touch_event.js +45 -80
- package/lib/handler/events/map_wheel_event.js +34 -58
- package/lib/handler/events/render_event.js +31 -52
- package/lib/handler/handler_inertia.js +113 -160
- package/lib/handler/handler_manager.js +379 -620
- package/lib/handler/handler_util.js +28 -10
- package/lib/handler/keyboard.js +114 -146
- package/lib/handler/map_event.js +84 -120
- package/lib/handler/mouse/index.js +35 -29
- package/lib/handler/mouse/mouse_handler.js +90 -123
- package/lib/handler/mouse/mousepan_handler.js +46 -65
- package/lib/handler/mouse/mousepitch_hander.js +44 -63
- package/lib/handler/mouse/mouserotate_hander.js +44 -63
- package/lib/handler/mouse/util.js +38 -20
- package/lib/handler/scroll_zoom.js +175 -258
- package/lib/handler/shim/dblclick_zoom.js +42 -48
- package/lib/handler/shim/drag_pan.js +48 -59
- package/lib/handler/shim/drag_rotate.js +43 -51
- package/lib/handler/shim/touch_zoom_rotate.js +58 -78
- package/lib/handler/tap/single_tap_recognizer.js +84 -117
- package/lib/handler/tap/tap_drag_zoom.js +92 -115
- package/lib/handler/tap/tap_recognizer.js +60 -78
- package/lib/handler/tap/tap_zoom.js +88 -119
- package/lib/handler/touch/index.js +38 -37
- package/lib/handler/touch/touch_pan.js +98 -132
- package/lib/handler/touch/touch_pitch.js +73 -117
- package/lib/handler/touch/touch_rotate.js +58 -94
- package/lib/handler/touch/touch_zoom.js +49 -84
- package/lib/handler/touch/two_touch.js +88 -128
- package/lib/hash.js +100 -133
- package/lib/index.js +19 -31
- package/lib/interface.js +17 -2
- package/lib/map.js +238 -420
- package/lib/util.js +67 -78
- package/lib/utils/Aabb.js +80 -132
- package/lib/utils/dom.js +84 -141
- package/lib/utils/performance.js +54 -42
- package/lib/utils/primitives.js +59 -51
- package/lib/utils/task_queue.js +61 -108
- package/package.json +11 -8
- package/es/camera.js.map +0 -1
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/map.js.map +0 -1
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.js.map +0 -1
- package/lib/camera.js.map +0 -1
- package/lib/earthmap.js.map +0 -1
- package/lib/geo/edge_insets.js.map +0 -1
- package/lib/geo/lng_lat.js.map +0 -1
- package/lib/geo/lng_lat_bounds.js.map +0 -1
- package/lib/geo/mercator.js.map +0 -1
- package/lib/geo/point.js.map +0 -1
- package/lib/geo/simple.js.map +0 -1
- package/lib/geo/transform.js.map +0 -1
- package/lib/handler/IHandler.js.map +0 -1
- package/lib/handler/blockable_map_event.js.map +0 -1
- package/lib/handler/box_zoom.js.map +0 -1
- package/lib/handler/click_zoom.js.map +0 -1
- package/lib/handler/events/event.js.map +0 -1
- package/lib/handler/events/index.js.map +0 -1
- package/lib/handler/events/map_mouse_event.js.map +0 -1
- package/lib/handler/events/map_touch_event.js.map +0 -1
- package/lib/handler/events/map_wheel_event.js.map +0 -1
- package/lib/handler/events/render_event.js.map +0 -1
- package/lib/handler/handler_inertia.js.map +0 -1
- package/lib/handler/handler_manager.js.map +0 -1
- package/lib/handler/handler_util.js.map +0 -1
- package/lib/handler/keyboard.js.map +0 -1
- package/lib/handler/map_event.js.map +0 -1
- package/lib/handler/mouse/index.js.map +0 -1
- package/lib/handler/mouse/mouse_handler.js.map +0 -1
- package/lib/handler/mouse/mousepan_handler.js.map +0 -1
- package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
- package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
- package/lib/handler/mouse/util.js.map +0 -1
- package/lib/handler/scroll_zoom.js.map +0 -1
- package/lib/handler/shim/dblclick_zoom.js.map +0 -1
- package/lib/handler/shim/drag_pan.js.map +0 -1
- package/lib/handler/shim/drag_rotate.js.map +0 -1
- package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
- package/lib/handler/tap/tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_zoom.js.map +0 -1
- package/lib/handler/touch/index.js.map +0 -1
- package/lib/handler/touch/touch_pan.js.map +0 -1
- package/lib/handler/touch/touch_pitch.js.map +0 -1
- package/lib/handler/touch/touch_rotate.js.map +0 -1
- package/lib/handler/touch/touch_zoom.js.map +0 -1
- package/lib/handler/touch/two_touch.js.map +0 -1
- package/lib/hash.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/map.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib/utils/Aabb.js.map +0 -1
- package/lib/utils/dom.js.map +0 -1
- package/lib/utils/performance.js.map +0 -1
- package/lib/utils/primitives.js.map +0 -1
- package/lib/utils/task_queue.js.map +0 -1
|
@@ -1,91 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/handler/touch/touch_zoom.ts
|
|
23
|
+
var touch_zoom_exports = {};
|
|
24
|
+
__export(touch_zoom_exports, {
|
|
25
|
+
default: () => TouchZoomHandler
|
|
7
26
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
|
-
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
27
|
-
|
|
28
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
29
|
-
|
|
30
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
|
|
27
|
+
module.exports = __toCommonJS(touch_zoom_exports);
|
|
28
|
+
var import_two_touch = __toESM(require("./two_touch"));
|
|
32
29
|
var ZOOM_THRESHOLD = 0.1;
|
|
33
|
-
|
|
34
30
|
function getZoomDelta(distance, lastDistance) {
|
|
35
31
|
return Math.log(distance / lastDistance) / Math.LN2;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function TouchZoomHandler() {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2.default)(this, TouchZoomHandler);
|
|
47
|
-
|
|
48
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
-
args[_key] = arguments[_key];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "distance", void 0);
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startDistance", void 0);
|
|
55
|
-
return _this;
|
|
33
|
+
var TouchZoomHandler = class extends import_two_touch.default {
|
|
34
|
+
reset() {
|
|
35
|
+
super.reset();
|
|
36
|
+
delete this.distance;
|
|
37
|
+
delete this.startDistance;
|
|
56
38
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, {
|
|
66
|
-
key: "start",
|
|
67
|
-
value: function start(points) {
|
|
68
|
-
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "move",
|
|
72
|
-
value: function move(points, pinchAround) {
|
|
73
|
-
var lastDistance = this.distance;
|
|
74
|
-
this.distance = points[0].dist(points[1]);
|
|
75
|
-
|
|
76
|
-
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.active = true;
|
|
81
|
-
return {
|
|
82
|
-
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
83
|
-
pinchAround: pinchAround
|
|
84
|
-
};
|
|
39
|
+
start(points) {
|
|
40
|
+
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
41
|
+
}
|
|
42
|
+
move(points, pinchAround) {
|
|
43
|
+
const lastDistance = this.distance;
|
|
44
|
+
this.distance = points[0].dist(points[1]);
|
|
45
|
+
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
46
|
+
return;
|
|
85
47
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
48
|
+
this.active = true;
|
|
49
|
+
return {
|
|
50
|
+
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
51
|
+
pinchAround
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {});
|
|
@@ -1,145 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/handler/touch/two_touch.ts
|
|
23
|
+
var two_touch_exports = {};
|
|
24
|
+
__export(two_touch_exports, {
|
|
25
|
+
default: () => TwoTouchHandler
|
|
7
26
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
|
-
var _dom = _interopRequireDefault(require("../../utils/dom"));
|
|
19
|
-
|
|
20
|
-
var TwoTouchHandler = function () {
|
|
21
|
-
function TwoTouchHandler() {
|
|
22
|
-
(0, _classCallCheck2.default)(this, TwoTouchHandler);
|
|
23
|
-
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
24
|
-
(0, _defineProperty2.default)(this, "active", void 0);
|
|
25
|
-
(0, _defineProperty2.default)(this, "firstTwoTouches", void 0);
|
|
26
|
-
(0, _defineProperty2.default)(this, "vector", void 0);
|
|
27
|
-
(0, _defineProperty2.default)(this, "startVector", void 0);
|
|
28
|
-
(0, _defineProperty2.default)(this, "aroundCenter", void 0);
|
|
27
|
+
module.exports = __toCommonJS(two_touch_exports);
|
|
28
|
+
var import_dom = __toESM(require("../../utils/dom"));
|
|
29
|
+
var TwoTouchHandler = class {
|
|
30
|
+
constructor() {
|
|
29
31
|
this.reset();
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
reset() {
|
|
34
|
+
this.active = false;
|
|
35
|
+
delete this.firstTwoTouches;
|
|
36
|
+
}
|
|
37
|
+
start(points) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
move(points, pinchAround, e) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
touchstart(e, points, mapTouches) {
|
|
44
|
+
if (this.firstTwoTouches || mapTouches.length < 2) {
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
48
|
+
this.start([points[0], points[1]]);
|
|
49
|
+
}
|
|
50
|
+
touchmove(e, points, mapTouches) {
|
|
51
|
+
if (!this.firstTwoTouches) {
|
|
46
52
|
return;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
56
|
-
this.start([points[0], points[1]]);
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "touchmove",
|
|
60
|
-
value: function touchmove(e, points, mapTouches) {
|
|
61
|
-
if (!this.firstTwoTouches) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
|
|
67
|
-
var _this$firstTwoTouches = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
|
|
68
|
-
idA = _this$firstTwoTouches[0],
|
|
69
|
-
idB = _this$firstTwoTouches[1];
|
|
70
|
-
|
|
71
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
72
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
73
|
-
|
|
74
|
-
if (!a || !b) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
79
|
-
return this.move([a, b], pinchAround, e);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "touchend",
|
|
83
|
-
value: function touchend(e, points, mapTouches) {
|
|
84
|
-
if (!this.firstTwoTouches) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var _this$firstTwoTouches2 = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
|
|
89
|
-
idA = _this$firstTwoTouches2[0],
|
|
90
|
-
idB = _this$firstTwoTouches2[1];
|
|
91
|
-
|
|
92
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
93
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
94
|
-
|
|
95
|
-
if (a && b) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (this.active) {
|
|
100
|
-
_dom.default.suppressClick();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.reset();
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "touchcancel",
|
|
107
|
-
value: function touchcancel() {
|
|
108
|
-
this.reset();
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "enable",
|
|
112
|
-
value: function enable(options) {
|
|
113
|
-
this.enabled = true;
|
|
114
|
-
this.aroundCenter = !!options && options.around === 'center';
|
|
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;
|
|
115
60
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
61
|
+
const pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
62
|
+
return this.move([a, b], pinchAround, e);
|
|
63
|
+
}
|
|
64
|
+
touchend(e, points, mapTouches) {
|
|
65
|
+
if (!this.firstTwoTouches) {
|
|
66
|
+
return;
|
|
121
67
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
68
|
+
const [idA, idB] = this.firstTwoTouches;
|
|
69
|
+
const a = getTouchById(mapTouches, points, idA);
|
|
70
|
+
const b = getTouchById(mapTouches, points, idB);
|
|
71
|
+
if (a && b) {
|
|
72
|
+
return;
|
|
126
73
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
value: function isActive() {
|
|
130
|
-
return this.active;
|
|
74
|
+
if (this.active) {
|
|
75
|
+
import_dom.default.suppressClick();
|
|
131
76
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
77
|
+
this.reset();
|
|
78
|
+
}
|
|
79
|
+
touchcancel() {
|
|
80
|
+
this.reset();
|
|
81
|
+
}
|
|
82
|
+
enable(options) {
|
|
83
|
+
this.enabled = true;
|
|
84
|
+
this.aroundCenter = !!options && options.around === "center";
|
|
85
|
+
}
|
|
86
|
+
disable() {
|
|
87
|
+
this.enabled = false;
|
|
88
|
+
this.reset();
|
|
89
|
+
}
|
|
90
|
+
isEnabled() {
|
|
91
|
+
return this.enabled;
|
|
92
|
+
}
|
|
93
|
+
isActive() {
|
|
94
|
+
return this.active;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
138
97
|
function getTouchById(mapTouches, points, identifier) {
|
|
139
|
-
for (
|
|
98
|
+
for (let i = 0; i < mapTouches.length; i++) {
|
|
140
99
|
if (mapTouches[i].identifier === identifier) {
|
|
141
100
|
return points[i];
|
|
142
101
|
}
|
|
143
102
|
}
|
|
144
103
|
}
|
|
145
|
-
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {});
|
package/lib/hash.js
CHANGED
|
@@ -1,153 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hash.ts
|
|
20
|
+
var hash_exports = {};
|
|
21
|
+
__export(hash_exports, {
|
|
22
|
+
default: () => hash_default
|
|
7
23
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
19
|
-
|
|
20
|
-
var Hash = function () {
|
|
21
|
-
function Hash(hashName) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
|
|
24
|
-
(0, _classCallCheck2.default)(this, Hash);
|
|
25
|
-
(0, _defineProperty2.default)(this, "map", void 0);
|
|
26
|
-
(0, _defineProperty2.default)(this, "updateHash", void 0);
|
|
27
|
-
(0, _defineProperty2.default)(this, "hashName", void 0);
|
|
28
|
-
(0, _defineProperty2.default)(this, "onHashChange", function () {
|
|
29
|
-
var loc = _this.getCurrentHash();
|
|
30
|
-
|
|
31
|
-
if (loc.length >= 3 && !loc.some(function (v) {
|
|
32
|
-
return isNaN(+v);
|
|
33
|
-
})) {
|
|
34
|
-
var bearing = _this.map.dragRotate.isEnabled() && _this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : _this.map.getBearing();
|
|
35
|
-
|
|
36
|
-
_this.map.jumpTo({
|
|
24
|
+
module.exports = __toCommonJS(hash_exports);
|
|
25
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
26
|
+
var import_lodash = require("lodash");
|
|
27
|
+
var Hash = class {
|
|
28
|
+
constructor(hashName) {
|
|
29
|
+
this.onHashChange = () => {
|
|
30
|
+
const loc = this.getCurrentHash();
|
|
31
|
+
if (loc.length >= 3 && !loc.some((v) => isNaN(+v))) {
|
|
32
|
+
const bearing = this.map.dragRotate.isEnabled() && this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this.map.getBearing();
|
|
33
|
+
this.map.jumpTo({
|
|
37
34
|
center: [+loc[2], +loc[1]],
|
|
38
35
|
zoom: +loc[0],
|
|
39
|
-
bearing
|
|
36
|
+
bearing,
|
|
40
37
|
pitch: +(loc[4] || 0)
|
|
41
38
|
});
|
|
42
|
-
|
|
43
39
|
return true;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return part.split('=');
|
|
55
|
-
}).forEach(function (part) {
|
|
56
|
-
if (part[0] === _this.hashName) {
|
|
42
|
+
};
|
|
43
|
+
this.getCurrentHash = () => {
|
|
44
|
+
const hash = window.location.hash.replace("#", "");
|
|
45
|
+
if (this.hashName) {
|
|
46
|
+
let keyval;
|
|
47
|
+
hash.split("&").map((part) => part.split("=")).forEach((part) => {
|
|
48
|
+
if (part[0] === this.hashName) {
|
|
57
49
|
keyval = part;
|
|
58
50
|
}
|
|
59
51
|
});
|
|
60
|
-
return (keyval ? keyval[1] ||
|
|
52
|
+
return (keyval ? keyval[1] || "" : "").split("/");
|
|
61
53
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var hash = _this.getHashString();
|
|
67
|
-
|
|
54
|
+
return hash.split("/");
|
|
55
|
+
};
|
|
56
|
+
this.updateHashUnthrottled = () => {
|
|
57
|
+
const hash = this.getHashString();
|
|
68
58
|
try {
|
|
69
|
-
window.history.replaceState(window.history.state,
|
|
70
|
-
} catch (SecurityError) {
|
|
71
|
-
|
|
59
|
+
window.history.replaceState(window.history.state, "", hash);
|
|
60
|
+
} catch (SecurityError) {
|
|
61
|
+
}
|
|
62
|
+
};
|
|
72
63
|
this.hashName = hashName && encodeURIComponent(hashName);
|
|
73
|
-
this.updateHash = (0,
|
|
64
|
+
this.updateHash = (0, import_lodash.throttle)(this.updateHashUnthrottled, 30 * 1e3 / 100);
|
|
74
65
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
addTo(map) {
|
|
67
|
+
this.map = map;
|
|
68
|
+
import_l7_utils.$window.addEventListener("hashchange", this.onHashChange, false);
|
|
69
|
+
this.map.on("moveend", this.updateHash);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
remove() {
|
|
73
|
+
import_l7_utils.$window.removeEventListener("hashchange", this.onHashChange, false);
|
|
74
|
+
this.map.off("moveend", this.updateHash);
|
|
75
|
+
delete this.map;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
getHashString(mapFeedback) {
|
|
79
|
+
const center = this.map.getCenter();
|
|
80
|
+
const zoom = Math.round(this.map.getZoom() * 100) / 100;
|
|
81
|
+
const precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
|
|
82
|
+
const m = Math.pow(10, precision);
|
|
83
|
+
const lng = Math.round(center.lng * m) / m;
|
|
84
|
+
const lat = Math.round(center.lat * m) / m;
|
|
85
|
+
const bearing = this.map.getBearing();
|
|
86
|
+
const pitch = this.map.getPitch();
|
|
87
|
+
let hash = "";
|
|
88
|
+
if (mapFeedback) {
|
|
89
|
+
hash += `/${lng}/${lat}/${zoom}`;
|
|
90
|
+
} else {
|
|
91
|
+
hash += `${zoom}/${lat}/${lng}`;
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value: function remove() {
|
|
89
|
-
_l7Utils.$window.removeEventListener('hashchange', this.onHashChange, false);
|
|
90
|
-
|
|
91
|
-
this.map.off('moveend', this.updateHash);
|
|
92
|
-
delete this.map;
|
|
93
|
-
return this;
|
|
93
|
+
if (bearing || pitch) {
|
|
94
|
+
hash += `/${Math.round(bearing * 10) / 10}`;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var hash = '';
|
|
107
|
-
|
|
108
|
-
if (mapFeedback) {
|
|
109
|
-
hash += "/".concat(lng, "/").concat(lat, "/").concat(zoom);
|
|
110
|
-
} else {
|
|
111
|
-
hash += "".concat(zoom, "/").concat(lat, "/").concat(lng);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (bearing || pitch) {
|
|
115
|
-
hash += "/".concat(Math.round(bearing * 10) / 10);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (pitch) {
|
|
119
|
-
hash += "/".concat(Math.round(pitch));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (this.hashName) {
|
|
123
|
-
var hashName = this.hashName;
|
|
124
|
-
var found = false;
|
|
125
|
-
var parts = window.location.hash.slice(1).split('&').map(function (part) {
|
|
126
|
-
var key = part.split('=')[0];
|
|
127
|
-
|
|
128
|
-
if (key === hashName) {
|
|
129
|
-
found = true;
|
|
130
|
-
return "".concat(key, "=").concat(hash);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return part;
|
|
134
|
-
}).filter(function (a) {
|
|
135
|
-
return a;
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (!found) {
|
|
139
|
-
parts.push("".concat(hashName, "=").concat(hash));
|
|
96
|
+
if (pitch) {
|
|
97
|
+
hash += `/${Math.round(pitch)}`;
|
|
98
|
+
}
|
|
99
|
+
if (this.hashName) {
|
|
100
|
+
const hashName = this.hashName;
|
|
101
|
+
let found = false;
|
|
102
|
+
const parts = window.location.hash.slice(1).split("&").map((part) => {
|
|
103
|
+
const key = part.split("=")[0];
|
|
104
|
+
if (key === hashName) {
|
|
105
|
+
found = true;
|
|
106
|
+
return `${key}=${hash}`;
|
|
140
107
|
}
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
return part;
|
|
109
|
+
}).filter((a) => a);
|
|
110
|
+
if (!found) {
|
|
111
|
+
parts.push(`${hashName}=${hash}`);
|
|
143
112
|
}
|
|
144
|
-
|
|
145
|
-
return "#".concat(hash);
|
|
113
|
+
return `#${parts.join("&")}`;
|
|
146
114
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
exports
|
|
153
|
-
//# sourceMappingURL=hash.js.map
|
|
115
|
+
return `#${hash}`;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var hash_default = Hash;
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {});
|