@antv/l7-map 2.17.12 → 2.18.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 (104) hide show
  1. package/es/camera.js +92 -149
  2. package/es/earthmap.js +15 -68
  3. package/es/geo/edge_insets.js +4 -14
  4. package/es/geo/lng_lat.js +5 -13
  5. package/es/geo/lng_lat_bounds.js +4 -17
  6. package/es/geo/mercator.js +2 -10
  7. package/es/geo/point.js +0 -7
  8. package/es/geo/simple.js +6 -11
  9. package/es/geo/transform.js +128 -138
  10. package/es/handler/blockable_map_event.js +7 -12
  11. package/es/handler/box_zoom.js +10 -30
  12. package/es/handler/click_zoom.js +0 -5
  13. package/es/handler/events/event.js +2 -3
  14. package/es/handler/events/map_mouse_event.js +2 -13
  15. package/es/handler/events/map_touch_event.js +2 -12
  16. package/es/handler/events/map_wheel_event.js +1 -12
  17. package/es/handler/events/render_event.js +0 -13
  18. package/es/handler/handler_inertia.js +8 -35
  19. package/es/handler/handler_manager.js +90 -197
  20. package/es/handler/handler_util.js +1 -2
  21. package/es/handler/keyboard.js +1 -20
  22. package/es/handler/map_event.js +3 -9
  23. package/es/handler/mouse/mouse_handler.js +11 -24
  24. package/es/handler/mouse/mousepan_handler.js +1 -11
  25. package/es/handler/mouse/mousepitch_hander.js +1 -11
  26. package/es/handler/mouse/mouserotate_hander.js +1 -11
  27. package/es/handler/mouse/util.js +2 -3
  28. package/es/handler/scroll_zoom.js +43 -71
  29. package/es/handler/shim/dblclick_zoom.js +4 -9
  30. package/es/handler/shim/drag_pan.js +6 -18
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +8 -23
  33. package/es/handler/tap/single_tap_recognizer.js +8 -31
  34. package/es/handler/tap/tap_drag_zoom.js +7 -15
  35. package/es/handler/tap/tap_recognizer.js +3 -11
  36. package/es/handler/tap/tap_zoom.js +1 -7
  37. package/es/handler/touch/touch_pan.js +4 -22
  38. package/es/handler/touch/touch_pitch.js +10 -27
  39. package/es/handler/touch/touch_rotate.js +8 -19
  40. package/es/handler/touch/touch_zoom.js +5 -18
  41. package/es/handler/touch/two_touch.js +19 -32
  42. package/es/hash.js +13 -35
  43. package/es/map.js +30 -107
  44. package/es/util.d.ts +3 -3
  45. package/es/util.js +20 -33
  46. package/es/utils/Aabb.js +10 -31
  47. package/es/utils/dom.js +33 -111
  48. package/es/utils/performance.js +9 -9
  49. package/es/utils/primitives.js +13 -11
  50. package/es/utils/task_queue.js +6 -23
  51. package/lib/camera.js +102 -179
  52. package/lib/earthmap.js +14 -83
  53. package/lib/geo/edge_insets.js +3 -18
  54. package/lib/geo/lng_lat.js +5 -18
  55. package/lib/geo/lng_lat_bounds.js +4 -20
  56. package/lib/geo/mercator.js +1 -22
  57. package/lib/geo/point.js +0 -8
  58. package/lib/geo/simple.js +5 -24
  59. package/lib/geo/transform.js +128 -170
  60. package/lib/handler/blockable_map_event.js +6 -14
  61. package/lib/handler/box_zoom.js +8 -39
  62. package/lib/handler/click_zoom.js +0 -6
  63. package/lib/handler/events/event.js +4 -7
  64. package/lib/handler/events/index.js +0 -4
  65. package/lib/handler/events/map_mouse_event.js +5 -22
  66. package/lib/handler/events/map_touch_event.js +2 -21
  67. package/lib/handler/events/map_wheel_event.js +1 -16
  68. package/lib/handler/events/render_event.js +0 -19
  69. package/lib/handler/handler_inertia.js +13 -44
  70. package/lib/handler/handler_manager.js +92 -222
  71. package/lib/handler/handler_util.js +1 -3
  72. package/lib/handler/keyboard.js +1 -22
  73. package/lib/handler/map_event.js +2 -11
  74. package/lib/handler/mouse/index.js +0 -4
  75. package/lib/handler/mouse/mouse_handler.js +10 -27
  76. package/lib/handler/mouse/mousepan_handler.js +1 -18
  77. package/lib/handler/mouse/mousepitch_hander.js +1 -17
  78. package/lib/handler/mouse/mouserotate_hander.js +1 -17
  79. package/lib/handler/mouse/util.js +2 -6
  80. package/lib/handler/scroll_zoom.js +43 -77
  81. package/lib/handler/shim/dblclick_zoom.js +4 -10
  82. package/lib/handler/shim/drag_pan.js +6 -20
  83. package/lib/handler/shim/drag_rotate.js +4 -11
  84. package/lib/handler/shim/touch_zoom_rotate.js +8 -25
  85. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  86. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  87. package/lib/handler/tap/tap_recognizer.js +2 -17
  88. package/lib/handler/tap/tap_zoom.js +0 -9
  89. package/lib/handler/touch/index.js +0 -5
  90. package/lib/handler/touch/touch_pan.js +4 -25
  91. package/lib/handler/touch/touch_pitch.js +10 -32
  92. package/lib/handler/touch/touch_rotate.js +8 -25
  93. package/lib/handler/touch/touch_zoom.js +5 -24
  94. package/lib/handler/touch/two_touch.js +18 -35
  95. package/lib/hash.js +12 -38
  96. package/lib/index.js +0 -8
  97. package/lib/map.js +30 -125
  98. package/lib/util.js +19 -46
  99. package/lib/utils/Aabb.js +10 -34
  100. package/lib/utils/dom.js +32 -118
  101. package/lib/utils/performance.js +9 -11
  102. package/lib/utils/primitives.js +13 -16
  103. package/lib/utils/task_queue.js +6 -24
  104. package/package.json +4 -4
@@ -4,38 +4,29 @@ import _get from "@babel/runtime/helpers/esm/get";
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
-
8
7
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
-
10
8
  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; } }
11
-
12
9
  // @ts-ignore
10
+
13
11
  import TwoTouchHandler from "./two_touch";
14
12
  var ZOOM_THRESHOLD = 0.1;
15
-
16
13
  function getZoomDelta(distance, lastDistance) {
17
14
  return Math.log(distance / lastDistance) / Math.LN2;
18
15
  }
19
-
20
16
  var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
21
17
  _inherits(TouchZoomHandler, _TwoTouchHandler);
22
-
23
18
  var _super = _createSuper(TouchZoomHandler);
24
-
25
19
  function TouchZoomHandler() {
26
20
  _classCallCheck(this, TouchZoomHandler);
27
-
28
21
  return _super.apply(this, arguments);
29
22
  }
30
-
31
23
  _createClass(TouchZoomHandler, [{
32
24
  key: "reset",
33
25
  value: function reset() {
34
- _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this); // @ts-ignore
35
-
36
-
37
- delete this.distance; // @ts-ignore
38
-
26
+ _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this);
27
+ // @ts-ignore
28
+ delete this.distance;
29
+ // @ts-ignore
39
30
  delete this.startDistance;
40
31
  }
41
32
  }, {
@@ -48,11 +39,9 @@ var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
48
39
  value: function move(points, pinchAround) {
49
40
  var lastDistance = this.distance;
50
41
  this.distance = points[0].dist(points[1]);
51
-
52
42
  if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
53
43
  return;
54
44
  }
55
-
56
45
  this.active = true;
57
46
  return {
58
47
  zoomDelta: getZoomDelta(this.distance, lastDistance),
@@ -60,8 +49,6 @@ var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
60
49
  };
61
50
  }
62
51
  }]);
63
-
64
52
  return TouchZoomHandler;
65
53
  }(TwoTouchHandler);
66
-
67
54
  export { TouchZoomHandler as default };
@@ -2,38 +2,37 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  // @ts-ignore
5
- import DOM from "../../utils/dom";
6
5
 
6
+ import DOM from "../../utils/dom";
7
7
  var TwoTouchHandler = /*#__PURE__*/function () {
8
8
  function TwoTouchHandler() {
9
9
  _classCallCheck(this, TwoTouchHandler);
10
-
11
10
  this.reset();
12
11
  }
13
-
14
12
  _createClass(TwoTouchHandler, [{
15
13
  key: "reset",
16
14
  value: function reset() {
17
- this.active = false; // @ts-ignore
18
-
15
+ this.active = false;
16
+ // @ts-ignore
19
17
  delete this.firstTwoTouches;
20
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
-
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
20
  }, {
23
21
  key: "start",
24
22
  value: function start(points) {
25
23
  return;
26
24
  } // eslint-disable-line
27
-
28
25
  }, {
29
26
  key: "move",
30
- value: function move( // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- points, // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
- pinchAround, // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ value: function move(
28
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+ points,
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ pinchAround,
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
33
  e) {
34
34
  return;
35
35
  } // eslint-disable-line
36
-
37
36
  }, {
38
37
  key: "touchstart",
39
38
  value: function touchstart(e, points, mapTouches) {
@@ -42,9 +41,9 @@ var TwoTouchHandler = /*#__PURE__*/function () {
42
41
  if (this.firstTwoTouches || mapTouches.length < 2) {
43
42
  return;
44
43
  }
44
+ this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
45
45
 
46
- this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier]; // implemented by child classes
47
-
46
+ // implemented by child classes
48
47
  this.start([points[0], points[1]]);
49
48
  }
50
49
  }, {
@@ -53,22 +52,18 @@ var TwoTouchHandler = /*#__PURE__*/function () {
53
52
  if (!this.firstTwoTouches) {
54
53
  return;
55
54
  }
56
-
57
55
  e.preventDefault();
58
-
59
56
  var _this$firstTwoTouches = _slicedToArray(this.firstTwoTouches, 2),
60
- idA = _this$firstTwoTouches[0],
61
- idB = _this$firstTwoTouches[1];
62
-
57
+ idA = _this$firstTwoTouches[0],
58
+ idB = _this$firstTwoTouches[1];
63
59
  var a = getTouchById(mapTouches, points, idA);
64
60
  var b = getTouchById(mapTouches, points, idB);
65
-
66
61
  if (!a || !b) {
67
62
  return;
68
63
  }
64
+ var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
69
65
 
70
- var pinchAround = this.aroundCenter ? null : a.add(b).div(2); // implemented by child classes
71
-
66
+ // implemented by child classes
72
67
  return this.move([a, b], pinchAround, e);
73
68
  }
74
69
  }, {
@@ -77,22 +72,17 @@ var TwoTouchHandler = /*#__PURE__*/function () {
77
72
  if (!this.firstTwoTouches) {
78
73
  return;
79
74
  }
80
-
81
75
  var _this$firstTwoTouches2 = _slicedToArray(this.firstTwoTouches, 2),
82
- idA = _this$firstTwoTouches2[0],
83
- idB = _this$firstTwoTouches2[1];
84
-
76
+ idA = _this$firstTwoTouches2[0],
77
+ idB = _this$firstTwoTouches2[1];
85
78
  var a = getTouchById(mapTouches, points, idA);
86
79
  var b = getTouchById(mapTouches, points, idB);
87
-
88
80
  if (a && b) {
89
81
  return;
90
82
  }
91
-
92
83
  if (this.active) {
93
84
  DOM.suppressClick();
94
85
  }
95
-
96
86
  this.reset();
97
87
  }
98
88
  }, {
@@ -123,12 +113,9 @@ var TwoTouchHandler = /*#__PURE__*/function () {
123
113
  return this.active;
124
114
  }
125
115
  }]);
126
-
127
116
  return TwoTouchHandler;
128
117
  }();
129
-
130
118
  export { TwoTouchHandler as default };
131
-
132
119
  function getTouchById(mapTouches, points, identifier) {
133
120
  for (var i = 0; i < mapTouches.length; i++) {
134
121
  if (mapTouches[i].identifier === identifier) {
package/es/hash.js CHANGED
@@ -3,9 +3,8 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  // @ts-ignore
5
5
  // tslint:disable-next-line:no-submodule-imports
6
- import { $window } from '@antv/l7-utils';
7
- import { throttle } from 'lodash';
8
-
6
+ import { lodashUtil } from '@antv/l7-utils';
7
+ var throttle = lodashUtil.throttle;
9
8
  /*
10
9
  * Adds the map's position to its page's location hash.
11
10
  * Passed as an option to the map object.
@@ -15,34 +14,26 @@ import { throttle } from 'lodash';
15
14
  var Hash = /*#__PURE__*/function () {
16
15
  function Hash(hashName) {
17
16
  var _this = this;
18
-
19
17
  _classCallCheck(this, Hash);
20
-
21
18
  _defineProperty(this, "onHashChange", function () {
22
19
  var loc = _this.getCurrentHash();
23
-
24
20
  if (loc.length >= 3 && !loc.some(function (v) {
25
21
  return isNaN(+v);
26
22
  })) {
27
23
  var bearing = _this.map.dragRotate.isEnabled() && _this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : _this.map.getBearing();
28
-
29
24
  _this.map.jumpTo({
30
25
  center: [+loc[2], +loc[1]],
31
26
  zoom: +loc[0],
32
27
  bearing: bearing,
33
28
  pitch: +(loc[4] || 0)
34
29
  });
35
-
36
30
  return true;
37
31
  }
38
-
39
32
  return false;
40
33
  });
41
-
42
34
  _defineProperty(this, "getCurrentHash", function () {
43
35
  // Get the current hash from location, stripped from its number sign
44
36
  var hash = window.location.hash.replace('#', '');
45
-
46
37
  if (_this.hashName) {
47
38
  // Split the parameter-styled hash into parts and find the value we need
48
39
  var keyval;
@@ -55,41 +46,39 @@ var Hash = /*#__PURE__*/function () {
55
46
  });
56
47
  return (keyval ? keyval[1] || '' : '').split('/');
57
48
  }
58
-
59
49
  return hash.split('/');
60
50
  });
61
-
62
51
  _defineProperty(this, "updateHashUnthrottled", function () {
63
52
  var hash = _this.getHashString();
64
-
65
53
  try {
66
54
  window.history.replaceState(window.history.state, '', hash);
67
- } catch (SecurityError) {// IE11 does not allow this if the page is within an iframe created
55
+ } catch (SecurityError) {
56
+ // IE11 does not allow this if the page is within an iframe created
68
57
  // with iframe.contentWindow.document.write(...).
69
58
  // https://github.com/mapbox/mapbox-gl-js/issues/7410
70
59
  }
71
60
  });
61
+ this.hashName = hashName && encodeURIComponent(hashName);
72
62
 
73
- this.hashName = hashName && encodeURIComponent(hashName); // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
74
-
63
+ // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
75
64
  this.updateHash = throttle(this.updateHashUnthrottled, 30 * 1000 / 100);
76
65
  }
77
-
78
66
  _createClass(Hash, [{
79
67
  key: "addTo",
80
68
  value: function addTo(map) {
81
69
  this.map = map;
82
- $window.addEventListener('hashchange', this.onHashChange, false);
70
+ window.addEventListener('hashchange', this.onHashChange, false);
83
71
  this.map.on('moveend', this.updateHash);
84
72
  return this;
85
73
  }
86
74
  }, {
87
75
  key: "remove",
88
76
  value: function remove() {
89
- $window.removeEventListener('hashchange', this.onHashChange, false);
90
- this.map.off('moveend', this.updateHash); // clearTimeout(this.updateHash());
91
- // @ts-ignore
77
+ window.removeEventListener('hashchange', this.onHashChange, false);
78
+ this.map.off('moveend', this.updateHash);
79
+ // clearTimeout(this.updateHash());
92
80
 
81
+ // @ts-ignore
93
82
  delete this.map;
94
83
  return this;
95
84
  }
@@ -97,8 +86,8 @@ var Hash = /*#__PURE__*/function () {
97
86
  key: "getHashString",
98
87
  value: function getHashString(mapFeedback) {
99
88
  var center = this.map.getCenter();
100
- var zoom = Math.round(this.map.getZoom() * 100) / 100; // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
101
-
89
+ var zoom = Math.round(this.map.getZoom() * 100) / 100;
90
+ // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
102
91
  var precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
103
92
  var m = Math.pow(10, precision);
104
93
  var lng = Math.round(center.lng * m) / m;
@@ -106,7 +95,6 @@ var Hash = /*#__PURE__*/function () {
106
95
  var bearing = this.map.getBearing();
107
96
  var pitch = this.map.getPitch();
108
97
  var hash = '';
109
-
110
98
  if (mapFeedback) {
111
99
  // new map feedback site has some constraints that don't allow
112
100
  // us to use the same hash format as we do for the Map hash option.
@@ -114,43 +102,33 @@ var Hash = /*#__PURE__*/function () {
114
102
  } else {
115
103
  hash += "".concat(zoom, "/").concat(lat, "/").concat(lng);
116
104
  }
117
-
118
105
  if (bearing || pitch) {
119
106
  hash += "/".concat(Math.round(bearing * 10) / 10);
120
107
  }
121
-
122
108
  if (pitch) {
123
109
  hash += "/".concat(Math.round(pitch));
124
110
  }
125
-
126
111
  if (this.hashName) {
127
112
  var hashName = this.hashName;
128
113
  var found = false;
129
114
  var parts = window.location.hash.slice(1).split('&').map(function (part) {
130
115
  var key = part.split('=')[0];
131
-
132
116
  if (key === hashName) {
133
117
  found = true;
134
118
  return "".concat(key, "=").concat(hash);
135
119
  }
136
-
137
120
  return part;
138
121
  }).filter(function (a) {
139
122
  return a;
140
123
  });
141
-
142
124
  if (!found) {
143
125
  parts.push("".concat(hashName, "=").concat(hash));
144
126
  }
145
-
146
127
  return "#".concat(parts.join('&'));
147
128
  }
148
-
149
129
  return "#".concat(hash);
150
130
  }
151
131
  }]);
152
-
153
132
  return Hash;
154
133
  }();
155
-
156
134
  export default Hash;