@antv/l7-map 2.16.1 → 2.16.2

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 (103) hide show
  1. package/es/camera.js +90 -148
  2. package/es/earthmap.js +13 -65
  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 +123 -132
  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 +0 -2
  14. package/es/handler/events/map_mouse_event.js +0 -12
  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 +6 -34
  19. package/es/handler/handler_manager.js +55 -147
  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 +4 -11
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +6 -16
  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 +9 -31
  43. package/es/map.js +16 -78
  44. package/es/util.js +18 -23
  45. package/es/utils/Aabb.js +10 -31
  46. package/es/utils/dom.js +24 -58
  47. package/es/utils/performance.js +8 -7
  48. package/es/utils/primitives.js +13 -11
  49. package/es/utils/task_queue.js +6 -23
  50. package/lib/camera.js +90 -168
  51. package/lib/earthmap.js +11 -79
  52. package/lib/geo/edge_insets.js +3 -18
  53. package/lib/geo/lng_lat.js +5 -18
  54. package/lib/geo/lng_lat_bounds.js +4 -20
  55. package/lib/geo/mercator.js +1 -22
  56. package/lib/geo/point.js +0 -8
  57. package/lib/geo/simple.js +5 -24
  58. package/lib/geo/transform.js +123 -164
  59. package/lib/handler/blockable_map_event.js +6 -14
  60. package/lib/handler/box_zoom.js +8 -39
  61. package/lib/handler/click_zoom.js +0 -6
  62. package/lib/handler/events/event.js +0 -5
  63. package/lib/handler/events/index.js +0 -4
  64. package/lib/handler/events/map_mouse_event.js +0 -19
  65. package/lib/handler/events/map_touch_event.js +1 -20
  66. package/lib/handler/events/map_wheel_event.js +1 -16
  67. package/lib/handler/events/render_event.js +0 -19
  68. package/lib/handler/handler_inertia.js +4 -37
  69. package/lib/handler/handler_manager.js +55 -171
  70. package/lib/handler/handler_util.js +1 -3
  71. package/lib/handler/keyboard.js +1 -22
  72. package/lib/handler/map_event.js +2 -11
  73. package/lib/handler/mouse/index.js +0 -4
  74. package/lib/handler/mouse/mouse_handler.js +10 -27
  75. package/lib/handler/mouse/mousepan_handler.js +0 -17
  76. package/lib/handler/mouse/mousepitch_hander.js +0 -16
  77. package/lib/handler/mouse/mouserotate_hander.js +0 -16
  78. package/lib/handler/mouse/util.js +2 -6
  79. package/lib/handler/scroll_zoom.js +43 -77
  80. package/lib/handler/shim/dblclick_zoom.js +4 -10
  81. package/lib/handler/shim/drag_pan.js +4 -13
  82. package/lib/handler/shim/drag_rotate.js +4 -11
  83. package/lib/handler/shim/touch_zoom_rotate.js +6 -18
  84. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  85. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  86. package/lib/handler/tap/tap_recognizer.js +2 -17
  87. package/lib/handler/tap/tap_zoom.js +0 -9
  88. package/lib/handler/touch/index.js +0 -5
  89. package/lib/handler/touch/touch_pan.js +4 -25
  90. package/lib/handler/touch/touch_pitch.js +9 -31
  91. package/lib/handler/touch/touch_rotate.js +7 -24
  92. package/lib/handler/touch/touch_zoom.js +4 -23
  93. package/lib/handler/touch/two_touch.js +18 -35
  94. package/lib/hash.js +8 -35
  95. package/lib/index.js +0 -8
  96. package/lib/map.js +14 -94
  97. package/lib/util.js +16 -34
  98. package/lib/utils/Aabb.js +10 -34
  99. package/lib/utils/dom.js +22 -64
  100. package/lib/utils/performance.js +8 -9
  101. package/lib/utils/primitives.js +13 -16
  102. package/lib/utils/task_queue.js +6 -24
  103. package/package.json +3 -3
@@ -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
@@ -5,7 +5,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  // tslint:disable-next-line:no-submodule-imports
6
6
  import { $window } from '@antv/l7-utils';
7
7
  import { throttle } from 'lodash';
8
-
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,26 +46,23 @@ 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) {
@@ -87,9 +75,10 @@ var Hash = /*#__PURE__*/function () {
87
75
  key: "remove",
88
76
  value: function remove() {
89
77
  $window.removeEventListener('hashchange', this.onHashChange, false);
90
- this.map.off('moveend', this.updateHash); // clearTimeout(this.updateHash());
91
- // @ts-ignore
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;
package/es/map.js CHANGED
@@ -6,59 +6,45 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
-
10
9
  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); }; }
11
-
12
10
  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; } }
13
-
14
11
  import { $window, DOM, isMini } from '@antv/l7-utils';
15
12
  import { merge } from 'lodash';
16
13
  import Camera from "./camera";
17
-
18
14
  function loadStyles(css, doc) {
19
15
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
20
16
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
21
-
22
17
  if (isMiniAli || isWeChatMiniProgram) {
23
18
  return;
24
19
  }
25
-
26
20
  if (!doc) doc = document;
27
-
28
21
  if (!doc) {
29
22
  return;
30
23
  }
31
-
32
24
  var head = doc.head || doc.getElementsByTagName('head')[0];
33
-
34
25
  if (!head) {
35
26
  head = doc.createElement('head');
36
27
  var body = doc.body || doc.getElementsByTagName('body')[0];
37
-
38
28
  if (body) {
39
29
  body.parentNode.insertBefore(head, body);
40
30
  } else {
41
31
  doc.documentElement.appendChild(head);
42
32
  }
43
33
  }
44
-
45
34
  var style = doc.createElement('style');
46
35
  style.type = 'text/css';
47
-
48
36
  if (style.styleSheet) {
49
37
  style.styleSheet.cssText = css;
50
38
  } else {
51
39
  style.appendChild(doc.createTextNode(css));
52
40
  }
53
-
54
41
  head.appendChild(style);
55
42
  return style;
56
43
  }
57
-
58
44
  loadStyles(".l7-map {\n font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n overflow: hidden;\n position: relative;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.l7-canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.l7-map:-webkit-full-screen {\n width: 100%;\n height: 100%;\n}\n\n.l7-canary {\n background-color: salmon;\n}\n\n.l7-canvas-container.l7-interactive,\n.l7-ctrl-group button.l7-ctrl-compass {\n cursor: -webkit-grab;\n cursor: grab;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.l7-canvas-container.l7-interactive.l7-track-pointer {\n cursor: pointer;\n}\n\n.l7-canvas-container.l7-interactive:active,\n.l7-ctrl-group button.l7-ctrl-compass:active {\n cursor: -webkit-grabbing;\n cursor: grabbing;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate,\n.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {\n -ms-touch-action: pan-x pan-y;\n touch-action: pan-x pan-y;\n}\n\n.l7-canvas-container.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: pinch-zoom;\n touch-action: pinch-zoom;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: none;\n touch-action: none;\n}\n\n.l7-ctrl-top-left,\n.l7-ctrl-top-right,\n.l7-ctrl-bottom-left,\n.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }\n.l7-ctrl-top-left { top: 0; left: 0; }\n.l7-ctrl-top-right { top: 0; right: 0; }\n.l7-ctrl-bottom-left { bottom: 0; left: 0; }\n.l7-ctrl-bottom-right { right: 0; bottom: 0; }\n\n.l7-ctrl {\n clear: both;\n pointer-events: auto;\n\n /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }\n.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }\n.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }\n.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }\n\n\n.l7-crosshair,\n.l7-crosshair .l7-interactive,\n.l7-crosshair .l7-interactive:active {\n cursor: crosshair;\n}\n\n.l7-boxzoom {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background: #fff;\n border: 2px dotted #202020;\n opacity: 0.5;\n z-index: 10;\n}\n");
59
45
  import LngLat from "./geo/lng_lat";
60
- import LngLatBounds from "./geo/lng_lat_bounds"; // @ts-ignore
61
-
46
+ import LngLatBounds from "./geo/lng_lat_bounds";
47
+ // @ts-ignore
62
48
  import Point from "./geo/point";
63
49
  import HandlerManager from "./handler/handler_manager";
64
50
  import Hash from "./hash";
@@ -66,8 +52,9 @@ import { renderframe } from "./util";
66
52
  import { PerformanceUtils } from "./utils/performance";
67
53
  import TaskQueue from "./utils/task_queue";
68
54
  var defaultMinZoom = -2;
69
- var defaultMaxZoom = 22; // the default values, but also the valid range
55
+ var defaultMaxZoom = 22;
70
56
 
57
+ // the default values, but also the valid range
71
58
  var defaultMinPitch = 0;
72
59
  var defaultMaxPitch = 60;
73
60
  var DefaultOptions = {
@@ -99,24 +86,16 @@ var DefaultOptions = {
99
86
  };
100
87
  export var Map = /*#__PURE__*/function (_Camera) {
101
88
  _inherits(Map, _Camera);
102
-
103
89
  var _super = _createSuper(Map);
104
-
105
90
  function Map(options) {
106
91
  var _this;
107
-
108
92
  _classCallCheck(this, Map);
109
-
110
93
  _this = _super.call(this, merge({}, DefaultOptions, options));
111
-
112
94
  _defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
113
-
114
95
  _defineProperty(_assertThisInitialized(_this), "trackResize", true);
115
-
116
96
  _defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
117
97
  _this.update();
118
98
  });
119
-
120
99
  _defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
121
100
  if (_this.trackResize) {
122
101
  _this.resize({
@@ -124,32 +103,26 @@ export var Map = /*#__PURE__*/function (_Camera) {
124
103
  }).update();
125
104
  }
126
105
  });
127
-
128
106
  if (isMini) {
129
107
  _this.initMiniContainer();
130
108
  } else {
131
109
  _this.initContainer();
132
110
  }
133
-
134
111
  _this.resize();
135
-
136
112
  _this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
137
-
138
113
  if (typeof window !== 'undefined') {
139
114
  window.addEventListener('online', _this.onWindowOnline, false);
140
115
  window.addEventListener('resize', _this.onWindowResize, false);
141
116
  window.addEventListener('orientationchange', _this.onWindowResize, false);
142
117
  }
143
-
144
118
  if (!isMini) {
145
119
  var hashName = typeof options.hash === 'string' && options.hash || undefined;
146
-
147
120
  if (options.hash) {
148
121
  _this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
149
122
  }
150
- } // don't set position from options if set through hash
151
-
123
+ }
152
124
 
125
+ // don't set position from options if set through hash
153
126
  if (!_this.hash || !_this.hash.onHashChange()) {
154
127
  _this.jumpTo({
155
128
  center: options.center,
@@ -157,47 +130,37 @@ export var Map = /*#__PURE__*/function (_Camera) {
157
130
  bearing: options.bearing,
158
131
  pitch: options.pitch
159
132
  });
160
-
161
133
  if (options.bounds) {
162
134
  _this.resize();
163
-
164
135
  _this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
165
136
  duration: 0
166
137
  }));
167
138
  }
168
139
  }
169
-
170
140
  return _this;
171
141
  }
172
-
173
142
  _createClass(Map, [{
174
143
  key: "resize",
175
144
  value: function resize(eventData) {
176
145
  var _this$containerDimens = this.containerDimensions(),
177
- _this$containerDimens2 = _slicedToArray(_this$containerDimens, 2),
178
- width = _this$containerDimens2[0],
179
- height = _this$containerDimens2[1];
180
-
181
- this.transform.resize(width, height); // 小程序环境不需要执行后续动作
182
-
146
+ _this$containerDimens2 = _slicedToArray(_this$containerDimens, 2),
147
+ width = _this$containerDimens2[0],
148
+ height = _this$containerDimens2[1];
149
+ this.transform.resize(width, height);
150
+ // 小程序环境不需要执行后续动作
183
151
  if (isMini) {
184
152
  return this;
185
153
  }
186
-
187
154
  var fireMoving = !this.moving;
188
-
189
155
  if (fireMoving) {
190
156
  this.stop();
191
157
  this.emit('movestart', new $window.Event('movestart', eventData));
192
158
  this.emit('move', new $window.Event('move', eventData));
193
159
  }
194
-
195
160
  this.emit('resize', new $window.Event('resize', eventData));
196
-
197
161
  if (fireMoving) {
198
162
  this.emit('moveend', new $window.Event('moveend', eventData));
199
163
  }
200
-
201
164
  return this;
202
165
  }
203
166
  }, {
@@ -239,8 +202,9 @@ export var Map = /*#__PURE__*/function (_Camera) {
239
202
  key: "setMaxBounds",
240
203
  value: function setMaxBounds(bounds) {
241
204
  this.transform.setMaxBounds(LngLatBounds.convert(bounds));
242
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
205
+ }
243
206
 
207
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
244
208
  }, {
245
209
  key: "setStyle",
246
210
  value: function setStyle(style) {
@@ -250,14 +214,11 @@ export var Map = /*#__PURE__*/function (_Camera) {
250
214
  key: "setMinZoom",
251
215
  value: function setMinZoom(minZoom) {
252
216
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
253
-
254
217
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
255
218
  this.transform.minZoom = minZoom;
256
-
257
219
  if (this.getZoom() < minZoom) {
258
220
  this.setZoom(minZoom);
259
221
  }
260
-
261
222
  return this;
262
223
  } else {
263
224
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -272,14 +233,11 @@ export var Map = /*#__PURE__*/function (_Camera) {
272
233
  key: "setMaxZoom",
273
234
  value: function setMaxZoom(maxZoom) {
274
235
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
275
-
276
236
  if (maxZoom >= this.transform.minZoom) {
277
237
  this.transform.maxZoom = maxZoom;
278
-
279
238
  if (this.getZoom() > maxZoom) {
280
239
  this.setZoom(maxZoom);
281
240
  }
282
-
283
241
  return this;
284
242
  } else {
285
243
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -294,18 +252,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
294
252
  key: "setMinPitch",
295
253
  value: function setMinPitch(minPitch) {
296
254
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
297
-
298
255
  if (minPitch < defaultMinPitch) {
299
256
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
300
257
  }
301
-
302
258
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
303
259
  this.transform.minPitch = minPitch;
304
-
305
260
  if (this.getPitch() < minPitch) {
306
261
  this.setPitch(minPitch);
307
262
  }
308
-
309
263
  return this;
310
264
  } else {
311
265
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -320,18 +274,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
320
274
  key: "setMaxPitch",
321
275
  value: function setMaxPitch(maxPitch) {
322
276
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
323
-
324
277
  if (maxPitch > defaultMaxPitch) {
325
278
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
326
279
  }
327
-
328
280
  if (maxPitch >= this.transform.minPitch) {
329
281
  this.transform.maxPitch = maxPitch;
330
-
331
282
  if (this.getPitch() > maxPitch) {
332
283
  this.setPitch(maxPitch);
333
284
  }
334
-
335
285
  return this;
336
286
  } else {
337
287
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -355,15 +305,13 @@ export var Map = /*#__PURE__*/function (_Camera) {
355
305
  }, {
356
306
  key: "remove",
357
307
  value: function remove() {
358
- this.container.removeChild(this.canvasContainer); // @ts-ignore
359
-
308
+ this.container.removeChild(this.canvasContainer);
309
+ // @ts-ignore
360
310
  this.canvasContainer = null;
361
-
362
311
  if (this.frame) {
363
312
  this.frame.cancel();
364
313
  this.frame = null;
365
314
  }
366
-
367
315
  this.renderTaskQueue.clear();
368
316
  }
369
317
  }, {
@@ -381,12 +329,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
381
329
  key: "triggerRepaint",
382
330
  value: function triggerRepaint() {
383
331
  var _this2 = this;
384
-
385
332
  if (!this.frame) {
386
333
  this.frame = renderframe(function (paintStartTimeStamp) {
387
334
  PerformanceUtils.frame(paintStartTimeStamp);
388
335
  _this2.frame = null;
389
-
390
336
  _this2.update(paintStartTimeStamp);
391
337
  });
392
338
  }
@@ -395,12 +341,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
395
341
  key: "update",
396
342
  value: function update(time) {
397
343
  var _this3 = this;
398
-
399
344
  if (!this.frame) {
400
345
  this.frame = renderframe(function (paintStartTimeStamp) {
401
346
  PerformanceUtils.frame(paintStartTimeStamp);
402
347
  _this3.frame = null;
403
-
404
348
  _this3.renderTaskQueue.run(time);
405
349
  });
406
350
  }
@@ -410,7 +354,6 @@ export var Map = /*#__PURE__*/function (_Camera) {
410
354
  value: function initContainer() {
411
355
  if (typeof this.options.container === 'string') {
412
356
  this.container = window.document.getElementById(this.options.container);
413
-
414
357
  if (!this.container) {
415
358
  throw new Error("Container '".concat(this.options.container, "' not found."));
416
359
  }
@@ -419,19 +362,17 @@ export var Map = /*#__PURE__*/function (_Camera) {
419
362
  } else {
420
363
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
421
364
  }
422
-
423
365
  var container = this.container;
424
366
  container.classList.add('l7-map');
425
367
  var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
426
-
427
368
  if (this.options.interactive) {
428
369
  canvasContainer.classList.add('l7-interactive');
429
370
  }
430
371
  }
372
+
431
373
  /**
432
374
  * 小程序环境构建容器
433
375
  */
434
-
435
376
  }, {
436
377
  key: "initMiniContainer",
437
378
  value: function initMiniContainer() {
@@ -443,7 +384,6 @@ export var Map = /*#__PURE__*/function (_Camera) {
443
384
  value: function containerDimensions() {
444
385
  var width = 0;
445
386
  var height = 0;
446
-
447
387
  if (this.container) {
448
388
  if (isMini) {
449
389
  width = this.container.width / $window.devicePixelRatio;
@@ -455,10 +395,8 @@ export var Map = /*#__PURE__*/function (_Camera) {
455
395
  height = height === 0 ? 300 : height;
456
396
  }
457
397
  }
458
-
459
398
  return [width, height];
460
399
  }
461
400
  }]);
462
-
463
401
  return Map;
464
402
  }(Camera);