@antv/l7-map 2.9.19 → 2.9.22-alpha.0

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 (223) hide show
  1. package/es/camera.js +115 -85
  2. package/es/css/l7.css +98 -0
  3. package/es/earthmap.js +27 -43
  4. package/es/geo/edge_insets.js +44 -14
  5. package/es/geo/lng_lat.js +15 -11
  6. package/es/geo/lng_lat_bounds.js +6 -10
  7. package/es/geo/mercator.js +24 -12
  8. package/es/geo/point.js +2 -8
  9. package/es/geo/simple.js +24 -12
  10. package/es/geo/transform.js +421 -120
  11. package/es/handler/IHandler.js +1 -2
  12. package/es/handler/blockable_map_event.js +13 -14
  13. package/es/handler/box_zoom.js +43 -27
  14. package/es/handler/click_zoom.js +3 -8
  15. package/es/handler/events/event.js +3 -6
  16. package/es/handler/events/index.js +4 -5
  17. package/es/handler/events/map_mouse_event.js +30 -20
  18. package/es/handler/events/map_touch_event.js +55 -25
  19. package/es/handler/events/map_wheel_event.js +24 -15
  20. package/es/handler/events/render_event.js +3 -6
  21. package/es/handler/handler_inertia.js +10 -12
  22. package/es/handler/handler_manager.js +75 -72
  23. package/es/handler/handler_util.js +2 -2
  24. package/es/handler/keyboard.js +20 -15
  25. package/es/handler/map_event.js +23 -12
  26. package/es/handler/mouse/index.js +4 -5
  27. package/es/handler/mouse/mouse_handler.js +17 -21
  28. package/es/handler/mouse/mousepan_handler.js +5 -5
  29. package/es/handler/mouse/mousepitch_hander.js +7 -5
  30. package/es/handler/mouse/mouserotate_hander.js +7 -5
  31. package/es/handler/mouse/util.js +3 -3
  32. package/es/handler/scroll_zoom.js +103 -67
  33. package/es/handler/shim/dblclick_zoom.js +35 -8
  34. package/es/handler/shim/drag_pan.js +48 -12
  35. package/es/handler/shim/drag_rotate.js +39 -10
  36. package/es/handler/shim/touch_zoom_rotate.js +59 -16
  37. package/es/handler/tap/single_tap_recognizer.js +7 -17
  38. package/es/handler/tap/tap_drag_zoom.js +5 -18
  39. package/es/handler/tap/tap_recognizer.js +4 -15
  40. package/es/handler/tap/tap_zoom.js +4 -13
  41. package/es/handler/touch/index.js +5 -6
  42. package/es/handler/touch/touch_pan.js +9 -20
  43. package/es/handler/touch/touch_pitch.js +11 -23
  44. package/es/handler/touch/touch_rotate.js +15 -18
  45. package/es/handler/touch/touch_zoom.js +5 -19
  46. package/es/handler/touch/two_touch.js +14 -21
  47. package/es/hash.js +28 -16
  48. package/es/index.js +2 -3
  49. package/es/interface.js +1 -2
  50. package/es/map.js +26 -47
  51. package/es/util.js +15 -6
  52. package/es/utils/Aabb.js +11 -12
  53. package/es/utils/dom.js +30 -11
  54. package/es/utils/performance.js +10 -6
  55. package/es/utils/primitives.js +11 -10
  56. package/es/utils/task_queue.js +6 -13
  57. package/lib/camera.js +508 -721
  58. package/lib/css/l7.css +98 -0
  59. package/lib/earthmap.js +222 -392
  60. package/lib/geo/edge_insets.js +64 -83
  61. package/lib/geo/lng_lat.js +65 -81
  62. package/lib/geo/lng_lat_bounds.js +124 -165
  63. package/lib/geo/mercator.js +62 -78
  64. package/lib/geo/point.js +171 -239
  65. package/lib/geo/simple.js +61 -80
  66. package/lib/geo/transform.js +470 -653
  67. package/lib/handler/IHandler.js +17 -2
  68. package/lib/handler/blockable_map_event.js +63 -83
  69. package/lib/handler/box_zoom.js +123 -176
  70. package/lib/handler/click_zoom.js +56 -68
  71. package/lib/handler/events/event.js +35 -23
  72. package/lib/handler/events/index.js +35 -29
  73. package/lib/handler/events/map_mouse_event.js +42 -72
  74. package/lib/handler/events/map_touch_event.js +45 -80
  75. package/lib/handler/events/map_wheel_event.js +34 -58
  76. package/lib/handler/events/render_event.js +31 -52
  77. package/lib/handler/handler_inertia.js +113 -160
  78. package/lib/handler/handler_manager.js +379 -620
  79. package/lib/handler/handler_util.js +28 -10
  80. package/lib/handler/keyboard.js +114 -146
  81. package/lib/handler/map_event.js +84 -120
  82. package/lib/handler/mouse/index.js +35 -29
  83. package/lib/handler/mouse/mouse_handler.js +90 -123
  84. package/lib/handler/mouse/mousepan_handler.js +46 -65
  85. package/lib/handler/mouse/mousepitch_hander.js +44 -63
  86. package/lib/handler/mouse/mouserotate_hander.js +44 -63
  87. package/lib/handler/mouse/util.js +38 -20
  88. package/lib/handler/scroll_zoom.js +175 -258
  89. package/lib/handler/shim/dblclick_zoom.js +42 -48
  90. package/lib/handler/shim/drag_pan.js +48 -59
  91. package/lib/handler/shim/drag_rotate.js +43 -51
  92. package/lib/handler/shim/touch_zoom_rotate.js +58 -78
  93. package/lib/handler/tap/single_tap_recognizer.js +84 -117
  94. package/lib/handler/tap/tap_drag_zoom.js +92 -115
  95. package/lib/handler/tap/tap_recognizer.js +60 -78
  96. package/lib/handler/tap/tap_zoom.js +88 -119
  97. package/lib/handler/touch/index.js +38 -37
  98. package/lib/handler/touch/touch_pan.js +98 -132
  99. package/lib/handler/touch/touch_pitch.js +73 -117
  100. package/lib/handler/touch/touch_rotate.js +58 -94
  101. package/lib/handler/touch/touch_zoom.js +49 -84
  102. package/lib/handler/touch/two_touch.js +88 -128
  103. package/lib/hash.js +100 -133
  104. package/lib/index.js +19 -31
  105. package/lib/interface.js +17 -2
  106. package/lib/map.js +238 -420
  107. package/lib/util.js +67 -78
  108. package/lib/utils/Aabb.js +80 -132
  109. package/lib/utils/dom.js +84 -141
  110. package/lib/utils/performance.js +54 -42
  111. package/lib/utils/primitives.js +59 -51
  112. package/lib/utils/task_queue.js +61 -108
  113. package/package.json +11 -8
  114. package/es/camera.js.map +0 -1
  115. package/es/earthmap.js.map +0 -1
  116. package/es/geo/edge_insets.js.map +0 -1
  117. package/es/geo/lng_lat.js.map +0 -1
  118. package/es/geo/lng_lat_bounds.js.map +0 -1
  119. package/es/geo/mercator.js.map +0 -1
  120. package/es/geo/point.js.map +0 -1
  121. package/es/geo/simple.js.map +0 -1
  122. package/es/geo/transform.js.map +0 -1
  123. package/es/handler/IHandler.js.map +0 -1
  124. package/es/handler/blockable_map_event.js.map +0 -1
  125. package/es/handler/box_zoom.js.map +0 -1
  126. package/es/handler/click_zoom.js.map +0 -1
  127. package/es/handler/events/event.js.map +0 -1
  128. package/es/handler/events/index.js.map +0 -1
  129. package/es/handler/events/map_mouse_event.js.map +0 -1
  130. package/es/handler/events/map_touch_event.js.map +0 -1
  131. package/es/handler/events/map_wheel_event.js.map +0 -1
  132. package/es/handler/events/render_event.js.map +0 -1
  133. package/es/handler/handler_inertia.js.map +0 -1
  134. package/es/handler/handler_manager.js.map +0 -1
  135. package/es/handler/handler_util.js.map +0 -1
  136. package/es/handler/keyboard.js.map +0 -1
  137. package/es/handler/map_event.js.map +0 -1
  138. package/es/handler/mouse/index.js.map +0 -1
  139. package/es/handler/mouse/mouse_handler.js.map +0 -1
  140. package/es/handler/mouse/mousepan_handler.js.map +0 -1
  141. package/es/handler/mouse/mousepitch_hander.js.map +0 -1
  142. package/es/handler/mouse/mouserotate_hander.js.map +0 -1
  143. package/es/handler/mouse/util.js.map +0 -1
  144. package/es/handler/scroll_zoom.js.map +0 -1
  145. package/es/handler/shim/dblclick_zoom.js.map +0 -1
  146. package/es/handler/shim/drag_pan.js.map +0 -1
  147. package/es/handler/shim/drag_rotate.js.map +0 -1
  148. package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
  149. package/es/handler/tap/single_tap_recognizer.js.map +0 -1
  150. package/es/handler/tap/tap_drag_zoom.js.map +0 -1
  151. package/es/handler/tap/tap_recognizer.js.map +0 -1
  152. package/es/handler/tap/tap_zoom.js.map +0 -1
  153. package/es/handler/touch/index.js.map +0 -1
  154. package/es/handler/touch/touch_pan.js.map +0 -1
  155. package/es/handler/touch/touch_pitch.js.map +0 -1
  156. package/es/handler/touch/touch_rotate.js.map +0 -1
  157. package/es/handler/touch/touch_zoom.js.map +0 -1
  158. package/es/handler/touch/two_touch.js.map +0 -1
  159. package/es/hash.js.map +0 -1
  160. package/es/index.js.map +0 -1
  161. package/es/interface.js.map +0 -1
  162. package/es/map.js.map +0 -1
  163. package/es/util.js.map +0 -1
  164. package/es/utils/Aabb.js.map +0 -1
  165. package/es/utils/dom.js.map +0 -1
  166. package/es/utils/performance.js.map +0 -1
  167. package/es/utils/primitives.js.map +0 -1
  168. package/es/utils/task_queue.js.map +0 -1
  169. package/lib/camera.js.map +0 -1
  170. package/lib/earthmap.js.map +0 -1
  171. package/lib/geo/edge_insets.js.map +0 -1
  172. package/lib/geo/lng_lat.js.map +0 -1
  173. package/lib/geo/lng_lat_bounds.js.map +0 -1
  174. package/lib/geo/mercator.js.map +0 -1
  175. package/lib/geo/point.js.map +0 -1
  176. package/lib/geo/simple.js.map +0 -1
  177. package/lib/geo/transform.js.map +0 -1
  178. package/lib/handler/IHandler.js.map +0 -1
  179. package/lib/handler/blockable_map_event.js.map +0 -1
  180. package/lib/handler/box_zoom.js.map +0 -1
  181. package/lib/handler/click_zoom.js.map +0 -1
  182. package/lib/handler/events/event.js.map +0 -1
  183. package/lib/handler/events/index.js.map +0 -1
  184. package/lib/handler/events/map_mouse_event.js.map +0 -1
  185. package/lib/handler/events/map_touch_event.js.map +0 -1
  186. package/lib/handler/events/map_wheel_event.js.map +0 -1
  187. package/lib/handler/events/render_event.js.map +0 -1
  188. package/lib/handler/handler_inertia.js.map +0 -1
  189. package/lib/handler/handler_manager.js.map +0 -1
  190. package/lib/handler/handler_util.js.map +0 -1
  191. package/lib/handler/keyboard.js.map +0 -1
  192. package/lib/handler/map_event.js.map +0 -1
  193. package/lib/handler/mouse/index.js.map +0 -1
  194. package/lib/handler/mouse/mouse_handler.js.map +0 -1
  195. package/lib/handler/mouse/mousepan_handler.js.map +0 -1
  196. package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
  197. package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
  198. package/lib/handler/mouse/util.js.map +0 -1
  199. package/lib/handler/scroll_zoom.js.map +0 -1
  200. package/lib/handler/shim/dblclick_zoom.js.map +0 -1
  201. package/lib/handler/shim/drag_pan.js.map +0 -1
  202. package/lib/handler/shim/drag_rotate.js.map +0 -1
  203. package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
  204. package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
  205. package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
  206. package/lib/handler/tap/tap_recognizer.js.map +0 -1
  207. package/lib/handler/tap/tap_zoom.js.map +0 -1
  208. package/lib/handler/touch/index.js.map +0 -1
  209. package/lib/handler/touch/touch_pan.js.map +0 -1
  210. package/lib/handler/touch/touch_pitch.js.map +0 -1
  211. package/lib/handler/touch/touch_rotate.js.map +0 -1
  212. package/lib/handler/touch/touch_zoom.js.map +0 -1
  213. package/lib/handler/touch/two_touch.js.map +0 -1
  214. package/lib/hash.js.map +0 -1
  215. package/lib/index.js.map +0 -1
  216. package/lib/interface.js.map +0 -1
  217. package/lib/map.js.map +0 -1
  218. package/lib/util.js.map +0 -1
  219. package/lib/utils/Aabb.js.map +0 -1
  220. package/lib/utils/dom.js.map +0 -1
  221. package/lib/utils/performance.js.map +0 -1
  222. package/lib/utils/primitives.js.map +0 -1
  223. package/lib/utils/task_queue.js.map +0 -1
@@ -1,91 +1,56 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
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.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 _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
- var TouchZoomHandler = function (_TwoTouchHandler) {
39
- (0, _inherits2.default)(TouchZoomHandler, _TwoTouchHandler);
40
-
41
- var _super = _createSuper(TouchZoomHandler);
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
- (0, _createClass2.default)(TouchZoomHandler, [{
59
- key: "reset",
60
- value: function reset() {
61
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchZoomHandler.prototype), "reset", this).call(this);
62
- delete this.distance;
63
- delete this.startDistance;
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
- return TouchZoomHandler;
88
- }(_two_touch.default);
89
-
90
- exports.default = TouchZoomHandler;
91
- //# sourceMappingURL=touch_zoom.js.map
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
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.default = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
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
- (0, _createClass2.default)(TwoTouchHandler, [{
33
- key: "reset",
34
- value: function reset() {
35
- this.active = false;
36
- delete this.firstTwoTouches;
37
- }
38
- }, {
39
- key: "start",
40
- value: function start(points) {
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
- key: "move",
45
- value: function move(points, pinchAround, e) {
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
- key: "touchstart",
50
- value: function touchstart(e, points, mapTouches) {
51
- if (this.firstTwoTouches || mapTouches.length < 2) {
52
- return;
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
- key: "disable",
118
- value: function disable() {
119
- this.enabled = false;
120
- this.reset();
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
- key: "isEnabled",
124
- value: function isEnabled() {
125
- return this.enabled;
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
- key: "isActive",
129
- value: function isActive() {
130
- return this.active;
74
+ if (this.active) {
75
+ import_dom.default.suppressClick();
131
76
  }
132
- }]);
133
- return TwoTouchHandler;
134
- }();
135
-
136
- exports.default = TwoTouchHandler;
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 (var i = 0; i < mapTouches.length; i++) {
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
- //# sourceMappingURL=two_touch.js.map
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
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.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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
- var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
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: 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
- (0, _defineProperty2.default)(this, "getCurrentHash", function () {
49
- var hash = window.location.hash.replace('#', '');
50
-
51
- if (_this.hashName) {
52
- var keyval;
53
- hash.split('&').map(function (part) {
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] || '' : '').split('/');
52
+ return (keyval ? keyval[1] || "" : "").split("/");
61
53
  }
62
-
63
- return hash.split('/');
64
- });
65
- (0, _defineProperty2.default)(this, "updateHashUnthrottled", function () {
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, '', hash);
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, _throttle2.default)(this.updateHashUnthrottled, 30 * 1000 / 100);
64
+ this.updateHash = (0, import_lodash.throttle)(this.updateHashUnthrottled, 30 * 1e3 / 100);
74
65
  }
75
-
76
- (0, _createClass2.default)(Hash, [{
77
- key: "addTo",
78
- value: function addTo(map) {
79
- this.map = map;
80
-
81
- _l7Utils.$window.addEventListener('hashchange', this.onHashChange, false);
82
-
83
- this.map.on('moveend', this.updateHash);
84
- return this;
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
- key: "remove",
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
- key: "getHashString",
97
- value: function getHashString(mapFeedback) {
98
- var center = this.map.getCenter();
99
- var zoom = Math.round(this.map.getZoom() * 100) / 100;
100
- var precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
101
- var m = Math.pow(10, precision);
102
- var lng = Math.round(center.lng * m) / m;
103
- var lat = Math.round(center.lat * m) / m;
104
- var bearing = this.map.getBearing();
105
- var pitch = this.map.getPitch();
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
- return "#".concat(parts.join('&'));
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
- return Hash;
149
- }();
150
-
151
- var _default = Hash;
152
- exports.default = _default;
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 = {});