@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,99 +1,124 @@
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);
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
21
4
 
22
- // src/handler/tap/tap_zoom.ts
23
- var tap_zoom_exports = {};
24
- __export(tap_zoom_exports, {
25
- default: () => TapZoomHandler
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(tap_zoom_exports);
28
- var import_tap_recognizer = __toESM(require("./tap_recognizer"));
29
- var TapZoomHandler = class {
30
- constructor() {
31
- this.zoomIn = new import_tap_recognizer.default({
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 _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
15
+
16
+ // @ts-ignore
17
+ var TapZoomHandler = /*#__PURE__*/function () {
18
+ function TapZoomHandler() {
19
+ (0, _classCallCheck2.default)(this, TapZoomHandler);
20
+ this.zoomIn = new _tap_recognizer.default({
32
21
  numTouches: 1,
33
22
  numTaps: 2
34
23
  });
35
- this.zoomOut = new import_tap_recognizer.default({
24
+ this.zoomOut = new _tap_recognizer.default({
36
25
  numTouches: 2,
37
26
  numTaps: 1
38
27
  });
39
28
  this.reset();
40
29
  }
41
- reset() {
42
- this.active = false;
43
- this.zoomIn.reset();
44
- this.zoomOut.reset();
45
- }
46
- touchstart(e, points, mapTouches) {
47
- this.zoomIn.touchstart(e, points, mapTouches);
48
- this.zoomOut.touchstart(e, points, mapTouches);
49
- }
50
- touchmove(e, points, mapTouches) {
51
- this.zoomIn.touchmove(e, points, mapTouches);
52
- this.zoomOut.touchmove(e, points, mapTouches);
53
- }
54
- touchend(e, points, mapTouches) {
55
- const zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
56
- const zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
57
- if (zoomInPoint) {
58
- this.active = true;
59
- e.preventDefault();
60
- setTimeout(() => this.reset(), 0);
61
- return {
62
- cameraAnimation: (map) => map.easeTo({
63
- duration: 300,
64
- zoom: map.getZoom() + 1,
65
- around: map.unproject(zoomInPoint)
66
- }, { originalEvent: e })
67
- };
68
- } else if (zoomOutPoint) {
69
- this.active = true;
70
- e.preventDefault();
71
- setTimeout(() => this.reset(), 0);
72
- return {
73
- cameraAnimation: (map) => map.easeTo({
74
- duration: 300,
75
- zoom: map.getZoom() - 1,
76
- around: map.unproject(zoomOutPoint)
77
- }, { originalEvent: e })
78
- };
30
+
31
+ (0, _createClass2.default)(TapZoomHandler, [{
32
+ key: "reset",
33
+ value: function reset() {
34
+ this.active = false;
35
+ this.zoomIn.reset();
36
+ this.zoomOut.reset();
79
37
  }
80
- }
81
- touchcancel() {
82
- this.reset();
83
- }
84
- enable() {
85
- this.enabled = true;
86
- }
87
- disable() {
88
- this.enabled = false;
89
- this.reset();
90
- }
91
- isEnabled() {
92
- return this.enabled;
93
- }
94
- isActive() {
95
- return this.active;
96
- }
97
- };
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {});
38
+ }, {
39
+ key: "touchstart",
40
+ value: function touchstart(e, points, mapTouches) {
41
+ this.zoomIn.touchstart(e, points, mapTouches);
42
+ this.zoomOut.touchstart(e, points, mapTouches);
43
+ }
44
+ }, {
45
+ key: "touchmove",
46
+ value: function touchmove(e, points, mapTouches) {
47
+ this.zoomIn.touchmove(e, points, mapTouches);
48
+ this.zoomOut.touchmove(e, points, mapTouches);
49
+ }
50
+ }, {
51
+ key: "touchend",
52
+ value: function touchend(e, points, mapTouches) {
53
+ var _this = this;
54
+
55
+ var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
56
+ var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
57
+
58
+ if (zoomInPoint) {
59
+ this.active = true;
60
+ e.preventDefault();
61
+ setTimeout(function () {
62
+ return _this.reset();
63
+ }, 0);
64
+ return {
65
+ cameraAnimation: function cameraAnimation(map) {
66
+ return map.easeTo({
67
+ duration: 300,
68
+ zoom: map.getZoom() + 1,
69
+ around: map.unproject(zoomInPoint)
70
+ }, {
71
+ originalEvent: e
72
+ });
73
+ }
74
+ };
75
+ } else if (zoomOutPoint) {
76
+ this.active = true;
77
+ e.preventDefault();
78
+ setTimeout(function () {
79
+ return _this.reset();
80
+ }, 0);
81
+ return {
82
+ cameraAnimation: function cameraAnimation(map) {
83
+ return map.easeTo({
84
+ duration: 300,
85
+ zoom: map.getZoom() - 1,
86
+ around: map.unproject(zoomOutPoint)
87
+ }, {
88
+ originalEvent: e
89
+ });
90
+ }
91
+ };
92
+ }
93
+ }
94
+ }, {
95
+ key: "touchcancel",
96
+ value: function touchcancel() {
97
+ this.reset();
98
+ }
99
+ }, {
100
+ key: "enable",
101
+ value: function enable() {
102
+ this.enabled = true;
103
+ }
104
+ }, {
105
+ key: "disable",
106
+ value: function disable() {
107
+ this.enabled = false;
108
+ this.reset();
109
+ }
110
+ }, {
111
+ key: "isEnabled",
112
+ value: function isEnabled() {
113
+ return this.enabled;
114
+ }
115
+ }, {
116
+ key: "isActive",
117
+ value: function isActive() {
118
+ return this.active;
119
+ }
120
+ }]);
121
+ return TapZoomHandler;
122
+ }();
123
+
124
+ exports.default = TapZoomHandler;
@@ -1,41 +1,39 @@
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);
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
21
4
 
22
- // src/handler/touch/index.ts
23
- var touch_exports = {};
24
- __export(touch_exports, {
25
- TouchPanHandler: () => import_touch_pan.default,
26
- TouchPitchHandler: () => import_touch_pitch.default,
27
- TouchRotateHandler: () => import_touch_rotate.default,
28
- TouchZoomHandler: () => import_touch_zoom.default
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "TouchPanHandler", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _touch_pan.default;
12
+ }
29
13
  });
30
- module.exports = __toCommonJS(touch_exports);
31
- var import_touch_pan = __toESM(require("./touch_pan"));
32
- var import_touch_pitch = __toESM(require("./touch_pitch"));
33
- var import_touch_rotate = __toESM(require("./touch_rotate"));
34
- var import_touch_zoom = __toESM(require("./touch_zoom"));
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- TouchPanHandler,
38
- TouchPitchHandler,
39
- TouchRotateHandler,
40
- TouchZoomHandler
14
+ Object.defineProperty(exports, "TouchPitchHandler", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _touch_pitch.default;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "TouchRotateHandler", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _touch_rotate.default;
24
+ }
41
25
  });
26
+ Object.defineProperty(exports, "TouchZoomHandler", {
27
+ enumerable: true,
28
+ get: function get() {
29
+ return _touch_zoom.default;
30
+ }
31
+ });
32
+
33
+ var _touch_pan = _interopRequireDefault(require("./touch_pan"));
34
+
35
+ var _touch_pitch = _interopRequireDefault(require("./touch_pitch"));
36
+
37
+ var _touch_rotate = _interopRequireDefault(require("./touch_rotate"));
38
+
39
+ var _touch_zoom = _interopRequireDefault(require("./touch_zoom"));
@@ -1,110 +1,138 @@
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_pan.ts
23
- var touch_pan_exports = {};
24
- __export(touch_pan_exports, {
25
- default: () => TouchPanHandler
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(touch_pan_exports);
28
- var import_point = __toESM(require("../../geo/point"));
29
- var import_handler_util = require("../handler_util");
30
- var TouchPanHandler = class {
31
- constructor(options) {
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 _point = _interopRequireDefault(require("../../geo/point"));
15
+
16
+ var _handler_util = require("../handler_util");
17
+
18
+ // @ts-ignore
19
+ var TouchPanHandler = /*#__PURE__*/function () {
20
+ function TouchPanHandler(options) {
21
+ (0, _classCallCheck2.default)(this, TouchPanHandler);
32
22
  this.minTouches = 1;
33
23
  this.clickTolerance = options.clickTolerance || 1;
34
24
  this.reset();
35
25
  }
36
- reset() {
37
- this.active = false;
38
- this.touches = {};
39
- this.sum = new import_point.default(0, 0);
40
- }
41
- touchstart(e, points, mapTouches) {
42
- return this.calculateTransform(e, points, mapTouches);
43
- }
44
- touchmove(e, points, mapTouches) {
45
- if (!this.active) {
46
- return;
26
+
27
+ (0, _createClass2.default)(TouchPanHandler, [{
28
+ key: "reset",
29
+ value: function reset() {
30
+ this.active = false;
31
+ this.touches = {};
32
+ this.sum = new _point.default(0, 0);
47
33
  }
48
- e.preventDefault();
49
- return this.calculateTransform(e, points, mapTouches);
50
- }
51
- touchend(e, points, mapTouches) {
52
- this.calculateTransform(e, points, mapTouches);
53
- if (this.active && mapTouches.length < this.minTouches) {
54
- this.reset();
34
+ }, {
35
+ key: "touchstart",
36
+ value: function touchstart(e, points, mapTouches) {
37
+ return this.calculateTransform(e, points, mapTouches);
55
38
  }
56
- }
57
- touchcancel() {
58
- this.reset();
59
- }
60
- enable() {
61
- this.enabled = true;
62
- }
63
- disable() {
64
- this.enabled = false;
65
- this.reset();
66
- }
67
- isEnabled() {
68
- return this.enabled;
69
- }
70
- isActive() {
71
- return this.active;
72
- }
73
- calculateTransform(e, points, mapTouches) {
74
- if (mapTouches.length > 0) {
75
- this.active = true;
39
+ }, {
40
+ key: "touchmove",
41
+ value: function touchmove(e, points, mapTouches) {
42
+ if (!this.active) {
43
+ return;
44
+ }
45
+
46
+ e.preventDefault();
47
+ return this.calculateTransform(e, points, mapTouches);
76
48
  }
77
- const touches = (0, import_handler_util.indexTouches)(mapTouches, points);
78
- const touchPointSum = new import_point.default(0, 0);
79
- const touchDeltaSum = new import_point.default(0, 0);
80
- let touchDeltaCount = 0;
81
- for (const identifier in touches) {
82
- if (touches[identifier]) {
83
- const point = touches[identifier];
84
- const prevPoint = this.touches[identifier];
85
- if (prevPoint) {
86
- touchPointSum._add(point);
87
- touchDeltaSum._add(point.sub(prevPoint));
88
- touchDeltaCount++;
89
- touches[identifier] = point;
90
- }
49
+ }, {
50
+ key: "touchend",
51
+ value: function touchend(e, points, mapTouches) {
52
+ this.calculateTransform(e, points, mapTouches);
53
+
54
+ if (this.active && mapTouches.length < this.minTouches) {
55
+ this.reset();
91
56
  }
92
57
  }
93
- this.touches = touches;
94
- if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
95
- return;
58
+ }, {
59
+ key: "touchcancel",
60
+ value: function touchcancel() {
61
+ this.reset();
96
62
  }
97
- const panDelta = touchDeltaSum.div(touchDeltaCount);
98
- this.sum._add(panDelta);
99
- if (this.sum.mag() < this.clickTolerance) {
100
- return;
63
+ }, {
64
+ key: "enable",
65
+ value: function enable() {
66
+ this.enabled = true;
101
67
  }
102
- const around = touchPointSum.div(touchDeltaCount);
103
- return {
104
- around,
105
- panDelta
106
- };
107
- }
108
- };
109
- // Annotate the CommonJS export names for ESM import in node:
110
- 0 && (module.exports = {});
68
+ }, {
69
+ key: "disable",
70
+ value: function disable() {
71
+ this.enabled = false;
72
+ this.reset();
73
+ }
74
+ }, {
75
+ key: "isEnabled",
76
+ value: function isEnabled() {
77
+ return this.enabled;
78
+ }
79
+ }, {
80
+ key: "isActive",
81
+ value: function isActive() {
82
+ return this.active;
83
+ }
84
+ }, {
85
+ key: "calculateTransform",
86
+ value: function calculateTransform(e, points, mapTouches) {
87
+ if (mapTouches.length > 0) {
88
+ this.active = true;
89
+ }
90
+
91
+ var touches = (0, _handler_util.indexTouches)(mapTouches, points);
92
+ var touchPointSum = new _point.default(0, 0);
93
+ var touchDeltaSum = new _point.default(0, 0);
94
+ var touchDeltaCount = 0;
95
+
96
+ for (var identifier in touches) {
97
+ if (touches[identifier]) {
98
+ var point = touches[identifier];
99
+ var prevPoint = this.touches[identifier];
100
+
101
+ if (prevPoint) {
102
+ touchPointSum._add(point);
103
+
104
+ touchDeltaSum._add(point.sub(prevPoint));
105
+
106
+ touchDeltaCount++;
107
+ touches[identifier] = point;
108
+ }
109
+ }
110
+ }
111
+
112
+ this.touches = touches;
113
+
114
+ if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
115
+ return;
116
+ } // @ts-ignore
117
+
118
+
119
+ var panDelta = touchDeltaSum.div(touchDeltaCount);
120
+
121
+ this.sum._add(panDelta);
122
+
123
+ if (this.sum.mag() < this.clickTolerance) {
124
+ return;
125
+ } // @ts-ignore
126
+
127
+
128
+ var around = touchPointSum.div(touchDeltaCount);
129
+ return {
130
+ around: around,
131
+ panDelta: panDelta
132
+ };
133
+ }
134
+ }]);
135
+ return TouchPanHandler;
136
+ }();
137
+
138
+ exports.default = TouchPanHandler;