@antv/l7-map 2.9.33 → 2.9.35

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.
Files changed (56) hide show
  1. package/lib/camera.js +766 -508
  2. package/lib/earthmap.js +389 -223
  3. package/lib/geo/edge_insets.js +117 -64
  4. package/lib/geo/lng_lat.js +86 -65
  5. package/lib/geo/lng_lat_bounds.js +162 -123
  6. package/lib/geo/mercator.js +91 -62
  7. package/lib/geo/point.js +234 -171
  8. package/lib/geo/simple.js +93 -61
  9. package/lib/geo/transform.js +982 -472
  10. package/lib/handler/IHandler.js +4 -16
  11. package/lib/handler/blockable_map_event.js +84 -63
  12. package/lib/handler/box_zoom.js +201 -123
  13. package/lib/handler/click_zoom.js +63 -55
  14. package/lib/handler/events/event.js +20 -35
  15. package/lib/handler/events/index.js +28 -35
  16. package/lib/handler/events/map_mouse_event.js +85 -42
  17. package/lib/handler/events/map_touch_event.js +116 -45
  18. package/lib/handler/events/map_wheel_event.js +70 -34
  19. package/lib/handler/events/render_event.js +50 -31
  20. package/lib/handler/handler_inertia.js +158 -114
  21. package/lib/handler/handler_manager.js +640 -381
  22. package/lib/handler/handler_util.js +11 -29
  23. package/lib/handler/keyboard.js +155 -114
  24. package/lib/handler/map_event.js +133 -84
  25. package/lib/handler/mouse/index.js +28 -35
  26. package/lib/handler/mouse/mouse_handler.js +126 -90
  27. package/lib/handler/mouse/mousepan_handler.js +64 -46
  28. package/lib/handler/mouse/mousepitch_hander.js +64 -44
  29. package/lib/handler/mouse/mouserotate_hander.js +64 -44
  30. package/lib/handler/mouse/util.js +22 -40
  31. package/lib/handler/scroll_zoom.js +318 -176
  32. package/lib/handler/shim/dblclick_zoom.js +76 -42
  33. package/lib/handler/shim/drag_pan.js +98 -48
  34. package/lib/handler/shim/drag_rotate.js +82 -43
  35. package/lib/handler/shim/touch_zoom_rotate.js +127 -59
  36. package/lib/handler/tap/single_tap_recognizer.js +113 -84
  37. package/lib/handler/tap/tap_drag_zoom.js +111 -93
  38. package/lib/handler/tap/tap_recognizer.js +72 -60
  39. package/lib/handler/tap/tap_zoom.js +113 -88
  40. package/lib/handler/touch/index.js +36 -38
  41. package/lib/handler/touch/touch_pan.js +126 -98
  42. package/lib/handler/touch/touch_pitch.js +108 -74
  43. package/lib/handler/touch/touch_rotate.js +93 -59
  44. package/lib/handler/touch/touch_zoom.js +71 -49
  45. package/lib/handler/touch/two_touch.js +129 -90
  46. package/lib/hash.js +149 -100
  47. package/lib/index.js +43 -20
  48. package/lib/interface.js +4 -16
  49. package/lib/map.js +420 -240
  50. package/lib/util.js +88 -69
  51. package/lib/utils/Aabb.js +134 -81
  52. package/lib/utils/dom.js +162 -88
  53. package/lib/utils/performance.js +46 -54
  54. package/lib/utils/primitives.js +53 -59
  55. package/lib/utils/task_queue.js +104 -61
  56. package/package.json +3 -3
@@ -1,55 +1,105 @@
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/handler/shim/drag_pan.ts
20
- var drag_pan_exports = {};
21
- __export(drag_pan_exports, {
22
- default: () => DragPanHandler
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
23
7
  });
24
- module.exports = __toCommonJS(drag_pan_exports);
25
- var import_l7_utils = require("@antv/l7-utils");
26
- var DragPanHandler = class {
27
- constructor(el, mousePan, touchPan) {
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _l7Utils = require("@antv/l7-utils");
15
+
16
+ /**
17
+ * The `DragPanHandler` allows the user to pan the map by clicking and dragging
18
+ * the cursor.
19
+ */
20
+ var DragPanHandler = /*#__PURE__*/function () {
21
+ /**
22
+ * @private
23
+ */
24
+ function DragPanHandler(el, mousePan, touchPan) {
25
+ (0, _classCallCheck2.default)(this, DragPanHandler);
28
26
  this.el = el;
29
27
  this.mousePan = mousePan;
30
28
  this.touchPan = touchPan;
31
29
  }
32
- enable(options) {
33
- this.inertiaOptions = options || {};
34
- this.mousePan.enable();
35
- this.touchPan.enable();
36
- if (!import_l7_utils.isMini) {
37
- this.el.classList.add("l7-touch-drag-pan");
30
+ /**
31
+ * Enables the "drag to pan" interaction.
32
+ *
33
+ * @param {Object} [options] Options object
34
+ * @param {number} [options.linearity=0] factor used to scale the drag velocity
35
+ * @param {Function} [options.easing=bezier(0, 0, 0.3, 1)] easing function applled to `map.panTo` when applying the drag.
36
+ * @param {number} [options.maxSpeed=1400] the maximum value of the drag velocity.
37
+ * @param {number} [options.deceleration=2500] the rate at which the speed reduces after the pan ends.
38
+ *
39
+ * @example
40
+ * map.dragPan.enable();
41
+ * @example
42
+ * map.dragPan.enable({
43
+ * linearity: 0.3,
44
+ * easing: bezier(0, 0, 0.3, 1),
45
+ * maxSpeed: 1400,
46
+ * deceleration: 2500,
47
+ * });
48
+ */
49
+
50
+
51
+ (0, _createClass2.default)(DragPanHandler, [{
52
+ key: "enable",
53
+ value: function enable(options) {
54
+ this.inertiaOptions = options || {};
55
+ this.mousePan.enable();
56
+ this.touchPan.enable();
57
+
58
+ if (!_l7Utils.isMini) {
59
+ this.el.classList.add('l7-touch-drag-pan');
60
+ }
38
61
  }
39
- }
40
- disable() {
41
- this.mousePan.disable();
42
- this.touchPan.disable();
43
- if (!import_l7_utils.isMini) {
44
- this.el.classList.remove("l7-touch-drag-pan");
62
+ /**
63
+ * Disables the "drag to pan" interaction.
64
+ *
65
+ * @example
66
+ * map.dragPan.disable();
67
+ */
68
+
69
+ }, {
70
+ key: "disable",
71
+ value: function disable() {
72
+ this.mousePan.disable();
73
+ this.touchPan.disable();
74
+
75
+ if (!_l7Utils.isMini) {
76
+ this.el.classList.remove('l7-touch-drag-pan');
77
+ }
45
78
  }
46
- }
47
- isEnabled() {
48
- return this.mousePan.isEnabled() && this.touchPan.isEnabled();
49
- }
50
- isActive() {
51
- return this.mousePan.isActive() || this.touchPan.isActive();
52
- }
53
- };
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {});
79
+ /**
80
+ * Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
81
+ *
82
+ * @returns {boolean} `true` if the "drag to pan" interaction is enabled.
83
+ */
84
+
85
+ }, {
86
+ key: "isEnabled",
87
+ value: function isEnabled() {
88
+ return this.mousePan.isEnabled() && this.touchPan.isEnabled();
89
+ }
90
+ /**
91
+ * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
92
+ *
93
+ * @returns {boolean} `true` if the "drag to pan" interaction is active.
94
+ */
95
+
96
+ }, {
97
+ key: "isActive",
98
+ value: function isActive() {
99
+ return this.mousePan.isActive() || this.touchPan.isActive();
100
+ }
101
+ }]);
102
+ return DragPanHandler;
103
+ }();
104
+
105
+ exports.default = DragPanHandler;
@@ -1,49 +1,88 @@
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/handler/shim/drag_rotate.ts
20
- var drag_rotate_exports = {};
21
- __export(drag_rotate_exports, {
22
- default: () => DragRotateHandler
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
23
7
  });
24
- module.exports = __toCommonJS(drag_rotate_exports);
25
- var DragRotateHandler = class {
26
- constructor(options, mouseRotate, mousePitch) {
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ /**
15
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
16
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
17
+ */
18
+ var DragRotateHandler = /*#__PURE__*/function () {
19
+ /**
20
+ * @param {Object} [options]
21
+ * @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
22
+ * bearing will snap to north.
23
+ * @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
24
+ * @private
25
+ */
26
+ function DragRotateHandler(options, mouseRotate, mousePitch) {
27
+ (0, _classCallCheck2.default)(this, DragRotateHandler);
27
28
  this.pitchWithRotate = options.pitchWithRotate;
28
29
  this.mouseRotate = mouseRotate;
29
30
  this.mousePitch = mousePitch;
30
31
  }
31
- enable() {
32
- this.mouseRotate.enable();
33
- if (this.pitchWithRotate) {
34
- this.mousePitch.enable();
32
+ /**
33
+ * Enables the "drag to rotate" interaction.
34
+ *
35
+ * @example
36
+ * map.dragRotate.enable();
37
+ */
38
+
39
+
40
+ (0, _createClass2.default)(DragRotateHandler, [{
41
+ key: "enable",
42
+ value: function enable() {
43
+ this.mouseRotate.enable();
44
+
45
+ if (this.pitchWithRotate) {
46
+ this.mousePitch.enable();
47
+ }
35
48
  }
36
- }
37
- disable() {
38
- this.mouseRotate.disable();
39
- this.mousePitch.disable();
40
- }
41
- isEnabled() {
42
- return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
43
- }
44
- isActive() {
45
- return this.mouseRotate.isActive() || this.mousePitch.isActive();
46
- }
47
- };
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {});
49
+ /**
50
+ * Disables the "drag to rotate" interaction.
51
+ *
52
+ * @example
53
+ * map.dragRotate.disable();
54
+ */
55
+
56
+ }, {
57
+ key: "disable",
58
+ value: function disable() {
59
+ this.mouseRotate.disable();
60
+ this.mousePitch.disable();
61
+ }
62
+ /**
63
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
64
+ *
65
+ * @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
66
+ */
67
+
68
+ }, {
69
+ key: "isEnabled",
70
+ value: function isEnabled() {
71
+ return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
72
+ }
73
+ /**
74
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
75
+ *
76
+ * @returns {boolean} `true` if the "drag to rotate" interaction is active.
77
+ */
78
+
79
+ }, {
80
+ key: "isActive",
81
+ value: function isActive() {
82
+ return this.mouseRotate.isActive() || this.mousePitch.isActive();
83
+ }
84
+ }]);
85
+ return DragRotateHandler;
86
+ }();
87
+
88
+ exports.default = DragRotateHandler;
@@ -1,30 +1,31 @@
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/handler/shim/touch_zoom_rotate.ts
20
- var touch_zoom_rotate_exports = {};
21
- __export(touch_zoom_rotate_exports, {
22
- default: () => TouchZoomRotateHandler
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
23
7
  });
24
- module.exports = __toCommonJS(touch_zoom_rotate_exports);
25
- var import_l7_utils = require("@antv/l7-utils");
26
- var TouchZoomRotateHandler = class {
27
- constructor(el, touchZoom, touchRotate, tapDragZoom) {
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _l7Utils = require("@antv/l7-utils");
15
+
16
+ /**
17
+ * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
18
+ * pinching on a touchscreen.
19
+ *
20
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
21
+ * hold the finger down and drag up or down to zoom in or out.
22
+ */
23
+ var TouchZoomRotateHandler = /*#__PURE__*/function () {
24
+ /**
25
+ * @private
26
+ */
27
+ function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
28
+ (0, _classCallCheck2.default)(this, TouchZoomRotateHandler);
28
29
  this.el = el;
29
30
  this.touchZoom = touchZoom;
30
31
  this.touchRotate = touchRotate;
@@ -32,40 +33,107 @@ var TouchZoomRotateHandler = class {
32
33
  this.rotationDisabled = false;
33
34
  this.enabled = true;
34
35
  }
35
- enable(options) {
36
- this.touchZoom.enable(options);
37
- if (!this.rotationDisabled) {
38
- this.touchRotate.enable(options);
36
+ /**
37
+ * Enables the "pinch to rotate and zoom" interaction.
38
+ *
39
+ * @param {Object} [options] Options object.
40
+ * @param {string} [options.around] If "center" is passed, map will zoom around the center
41
+ *
42
+ * @example
43
+ * map.touchZoomRotate.enable();
44
+ * @example
45
+ * map.touchZoomRotate.enable({ around: 'center' });
46
+ */
47
+
48
+
49
+ (0, _createClass2.default)(TouchZoomRotateHandler, [{
50
+ key: "enable",
51
+ value: function enable(options) {
52
+ this.touchZoom.enable(options);
53
+
54
+ if (!this.rotationDisabled) {
55
+ this.touchRotate.enable(options);
56
+ }
57
+
58
+ this.tapDragZoom.enable();
59
+
60
+ if (!_l7Utils.isMini) {
61
+ this.el.classList.add('l7-touch-zoom-rotate');
62
+ }
39
63
  }
40
- this.tapDragZoom.enable();
41
- if (!import_l7_utils.isMini) {
42
- this.el.classList.add("l7-touch-zoom-rotate");
64
+ /**
65
+ * Disables the "pinch to rotate and zoom" interaction.
66
+ *
67
+ * @example
68
+ * map.touchZoomRotate.disable();
69
+ */
70
+
71
+ }, {
72
+ key: "disable",
73
+ value: function disable() {
74
+ this.touchZoom.disable();
75
+ this.touchRotate.disable();
76
+ this.tapDragZoom.disable();
77
+
78
+ if (!_l7Utils.isMini) {
79
+ this.el.classList.remove('l7-touch-zoom-rotate');
80
+ }
43
81
  }
44
- }
45
- disable() {
46
- this.touchZoom.disable();
47
- this.touchRotate.disable();
48
- this.tapDragZoom.disable();
49
- if (!import_l7_utils.isMini) {
50
- this.el.classList.remove("l7-touch-zoom-rotate");
82
+ /**
83
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
84
+ *
85
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
86
+ */
87
+
88
+ }, {
89
+ key: "isEnabled",
90
+ value: function isEnabled() {
91
+ return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
51
92
  }
52
- }
53
- isEnabled() {
54
- return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
55
- }
56
- isActive() {
57
- return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
58
- }
59
- disableRotation() {
60
- this.rotationDisabled = true;
61
- this.touchRotate.disable();
62
- }
63
- enableRotation() {
64
- this.rotationDisabled = false;
65
- if (this.touchZoom.isEnabled()) {
66
- this.touchRotate.enable();
93
+ /**
94
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
95
+ *
96
+ * @returns {boolean} //eslint-disable-line
97
+ */
98
+
99
+ }, {
100
+ key: "isActive",
101
+ value: function isActive() {
102
+ return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
67
103
  }
68
- }
69
- };
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {});
104
+ /**
105
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
106
+ * interaction enabled.
107
+ *
108
+ * @example
109
+ * map.touchZoomRotate.disableRotation();
110
+ */
111
+
112
+ }, {
113
+ key: "disableRotation",
114
+ value: function disableRotation() {
115
+ this.rotationDisabled = true;
116
+ this.touchRotate.disable();
117
+ }
118
+ /**
119
+ * Enables the "pinch to rotate" interaction.
120
+ *
121
+ * @example
122
+ * map.touchZoomRotate.enable();
123
+ * map.touchZoomRotate.enableRotation();
124
+ */
125
+
126
+ }, {
127
+ key: "enableRotation",
128
+ value: function enableRotation() {
129
+ this.rotationDisabled = false;
130
+
131
+ if (this.touchZoom.isEnabled()) {
132
+ this.touchRotate.enable();
133
+ }
134
+ }
135
+ }]);
136
+ return TouchZoomRotateHandler;
137
+ }();
138
+
139
+ exports.default = TouchZoomRotateHandler;