@antv/l7-map 2.17.11 → 2.17.12

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 +148 -90
  2. package/es/earthmap.js +65 -13
  3. package/es/geo/edge_insets.js +14 -4
  4. package/es/geo/lng_lat.js +13 -5
  5. package/es/geo/lng_lat_bounds.js +17 -4
  6. package/es/geo/mercator.js +10 -2
  7. package/es/geo/point.js +7 -0
  8. package/es/geo/simple.js +11 -6
  9. package/es/geo/transform.js +132 -127
  10. package/es/handler/blockable_map_event.js +12 -7
  11. package/es/handler/box_zoom.js +30 -10
  12. package/es/handler/click_zoom.js +5 -0
  13. package/es/handler/events/event.js +2 -0
  14. package/es/handler/events/map_mouse_event.js +12 -0
  15. package/es/handler/events/map_touch_event.js +12 -2
  16. package/es/handler/events/map_wheel_event.js +12 -1
  17. package/es/handler/events/render_event.js +13 -0
  18. package/es/handler/handler_inertia.js +34 -6
  19. package/es/handler/handler_manager.js +147 -55
  20. package/es/handler/handler_util.js +2 -1
  21. package/es/handler/keyboard.js +20 -1
  22. package/es/handler/map_event.js +9 -3
  23. package/es/handler/mouse/mouse_handler.js +24 -11
  24. package/es/handler/mouse/mousepan_handler.js +11 -1
  25. package/es/handler/mouse/mousepitch_hander.js +11 -1
  26. package/es/handler/mouse/mouserotate_hander.js +11 -1
  27. package/es/handler/mouse/util.js +3 -2
  28. package/es/handler/scroll_zoom.js +71 -43
  29. package/es/handler/shim/dblclick_zoom.js +9 -4
  30. package/es/handler/shim/drag_pan.js +11 -4
  31. package/es/handler/shim/drag_rotate.js +10 -4
  32. package/es/handler/shim/touch_zoom_rotate.js +16 -6
  33. package/es/handler/tap/single_tap_recognizer.js +31 -8
  34. package/es/handler/tap/tap_drag_zoom.js +15 -7
  35. package/es/handler/tap/tap_recognizer.js +11 -3
  36. package/es/handler/tap/tap_zoom.js +7 -1
  37. package/es/handler/touch/touch_pan.js +22 -4
  38. package/es/handler/touch/touch_pitch.js +27 -10
  39. package/es/handler/touch/touch_rotate.js +19 -8
  40. package/es/handler/touch/touch_zoom.js +18 -5
  41. package/es/handler/touch/two_touch.js +32 -19
  42. package/es/hash.js +31 -9
  43. package/es/map.js +78 -16
  44. package/es/util.js +26 -18
  45. package/es/utils/Aabb.js +31 -10
  46. package/es/utils/dom.js +58 -24
  47. package/es/utils/performance.js +7 -8
  48. package/es/utils/primitives.js +11 -13
  49. package/es/utils/task_queue.js +23 -6
  50. package/lib/camera.js +169 -91
  51. package/lib/earthmap.js +80 -12
  52. package/lib/geo/edge_insets.js +18 -3
  53. package/lib/geo/lng_lat.js +18 -5
  54. package/lib/geo/lng_lat_bounds.js +20 -4
  55. package/lib/geo/mercator.js +22 -1
  56. package/lib/geo/point.js +8 -0
  57. package/lib/geo/simple.js +24 -5
  58. package/lib/geo/transform.js +164 -127
  59. package/lib/handler/blockable_map_event.js +14 -6
  60. package/lib/handler/box_zoom.js +39 -8
  61. package/lib/handler/click_zoom.js +6 -0
  62. package/lib/handler/events/event.js +5 -0
  63. package/lib/handler/events/index.js +4 -0
  64. package/lib/handler/events/map_mouse_event.js +20 -2
  65. package/lib/handler/events/map_touch_event.js +21 -2
  66. package/lib/handler/events/map_wheel_event.js +16 -1
  67. package/lib/handler/events/render_event.js +19 -0
  68. package/lib/handler/handler_inertia.js +37 -5
  69. package/lib/handler/handler_manager.js +171 -56
  70. package/lib/handler/handler_util.js +3 -1
  71. package/lib/handler/keyboard.js +22 -1
  72. package/lib/handler/map_event.js +11 -2
  73. package/lib/handler/mouse/index.js +4 -0
  74. package/lib/handler/mouse/mouse_handler.js +27 -10
  75. package/lib/handler/mouse/mousepan_handler.js +18 -1
  76. package/lib/handler/mouse/mousepitch_hander.js +17 -1
  77. package/lib/handler/mouse/mouserotate_hander.js +17 -1
  78. package/lib/handler/mouse/util.js +6 -2
  79. package/lib/handler/scroll_zoom.js +77 -43
  80. package/lib/handler/shim/dblclick_zoom.js +10 -4
  81. package/lib/handler/shim/drag_pan.js +13 -4
  82. package/lib/handler/shim/drag_rotate.js +11 -4
  83. package/lib/handler/shim/touch_zoom_rotate.js +18 -6
  84. package/lib/handler/tap/single_tap_recognizer.js +33 -8
  85. package/lib/handler/tap/tap_drag_zoom.js +18 -6
  86. package/lib/handler/tap/tap_recognizer.js +17 -2
  87. package/lib/handler/tap/tap_zoom.js +9 -0
  88. package/lib/handler/touch/index.js +5 -0
  89. package/lib/handler/touch/touch_pan.js +25 -4
  90. package/lib/handler/touch/touch_pitch.js +32 -10
  91. package/lib/handler/touch/touch_rotate.js +25 -8
  92. package/lib/handler/touch/touch_zoom.js +24 -5
  93. package/lib/handler/touch/two_touch.js +35 -18
  94. package/lib/hash.js +35 -8
  95. package/lib/index.js +8 -0
  96. package/lib/map.js +95 -15
  97. package/lib/util.js +38 -16
  98. package/lib/utils/Aabb.js +34 -10
  99. package/lib/utils/dom.js +64 -22
  100. package/lib/utils/performance.js +9 -8
  101. package/lib/utils/primitives.js +16 -13
  102. package/lib/utils/task_queue.js +24 -6
  103. package/package.json +3 -3
@@ -4,29 +4,38 @@ 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
+
7
8
  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
+
8
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; } }
9
- // @ts-ignore
10
11
 
12
+ // @ts-ignore
11
13
  import TwoTouchHandler from "./two_touch";
12
14
  var ZOOM_THRESHOLD = 0.1;
15
+
13
16
  function getZoomDelta(distance, lastDistance) {
14
17
  return Math.log(distance / lastDistance) / Math.LN2;
15
18
  }
19
+
16
20
  var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
17
21
  _inherits(TouchZoomHandler, _TwoTouchHandler);
22
+
18
23
  var _super = _createSuper(TouchZoomHandler);
24
+
19
25
  function TouchZoomHandler() {
20
26
  _classCallCheck(this, TouchZoomHandler);
27
+
21
28
  return _super.apply(this, arguments);
22
29
  }
30
+
23
31
  _createClass(TouchZoomHandler, [{
24
32
  key: "reset",
25
33
  value: function reset() {
26
- _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this);
27
- // @ts-ignore
28
- delete this.distance;
29
- // @ts-ignore
34
+ _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this); // @ts-ignore
35
+
36
+
37
+ delete this.distance; // @ts-ignore
38
+
30
39
  delete this.startDistance;
31
40
  }
32
41
  }, {
@@ -39,9 +48,11 @@ var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
39
48
  value: function move(points, pinchAround) {
40
49
  var lastDistance = this.distance;
41
50
  this.distance = points[0].dist(points[1]);
51
+
42
52
  if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
43
53
  return;
44
54
  }
55
+
45
56
  this.active = true;
46
57
  return {
47
58
  zoomDelta: getZoomDelta(this.distance, lastDistance),
@@ -49,6 +60,8 @@ var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
49
60
  };
50
61
  }
51
62
  }]);
63
+
52
64
  return TouchZoomHandler;
53
65
  }(TwoTouchHandler);
66
+
54
67
  export { TouchZoomHandler as default };
@@ -2,37 +2,38 @@ 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
-
6
5
  import DOM from "../../utils/dom";
6
+
7
7
  var TwoTouchHandler = /*#__PURE__*/function () {
8
8
  function TwoTouchHandler() {
9
9
  _classCallCheck(this, TwoTouchHandler);
10
+
10
11
  this.reset();
11
12
  }
13
+
12
14
  _createClass(TwoTouchHandler, [{
13
15
  key: "reset",
14
16
  value: function reset() {
15
- this.active = false;
16
- // @ts-ignore
17
+ this.active = false; // @ts-ignore
18
+
17
19
  delete this.firstTwoTouches;
18
- }
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+
20
22
  }, {
21
23
  key: "start",
22
24
  value: function start(points) {
23
25
  return;
24
26
  } // eslint-disable-line
27
+
25
28
  }, {
26
29
  key: "move",
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
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
33
33
  e) {
34
34
  return;
35
35
  } // eslint-disable-line
36
+
36
37
  }, {
37
38
  key: "touchstart",
38
39
  value: function touchstart(e, points, mapTouches) {
@@ -41,9 +42,9 @@ var TwoTouchHandler = /*#__PURE__*/function () {
41
42
  if (this.firstTwoTouches || mapTouches.length < 2) {
42
43
  return;
43
44
  }
44
- this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
45
45
 
46
- // implemented by child classes
46
+ this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier]; // implemented by child classes
47
+
47
48
  this.start([points[0], points[1]]);
48
49
  }
49
50
  }, {
@@ -52,18 +53,22 @@ var TwoTouchHandler = /*#__PURE__*/function () {
52
53
  if (!this.firstTwoTouches) {
53
54
  return;
54
55
  }
56
+
55
57
  e.preventDefault();
58
+
56
59
  var _this$firstTwoTouches = _slicedToArray(this.firstTwoTouches, 2),
57
- idA = _this$firstTwoTouches[0],
58
- idB = _this$firstTwoTouches[1];
60
+ idA = _this$firstTwoTouches[0],
61
+ idB = _this$firstTwoTouches[1];
62
+
59
63
  var a = getTouchById(mapTouches, points, idA);
60
64
  var b = getTouchById(mapTouches, points, idB);
65
+
61
66
  if (!a || !b) {
62
67
  return;
63
68
  }
64
- var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
65
69
 
66
- // implemented by child classes
70
+ var pinchAround = this.aroundCenter ? null : a.add(b).div(2); // implemented by child classes
71
+
67
72
  return this.move([a, b], pinchAround, e);
68
73
  }
69
74
  }, {
@@ -72,17 +77,22 @@ var TwoTouchHandler = /*#__PURE__*/function () {
72
77
  if (!this.firstTwoTouches) {
73
78
  return;
74
79
  }
80
+
75
81
  var _this$firstTwoTouches2 = _slicedToArray(this.firstTwoTouches, 2),
76
- idA = _this$firstTwoTouches2[0],
77
- idB = _this$firstTwoTouches2[1];
82
+ idA = _this$firstTwoTouches2[0],
83
+ idB = _this$firstTwoTouches2[1];
84
+
78
85
  var a = getTouchById(mapTouches, points, idA);
79
86
  var b = getTouchById(mapTouches, points, idB);
87
+
80
88
  if (a && b) {
81
89
  return;
82
90
  }
91
+
83
92
  if (this.active) {
84
93
  DOM.suppressClick();
85
94
  }
95
+
86
96
  this.reset();
87
97
  }
88
98
  }, {
@@ -113,9 +123,12 @@ var TwoTouchHandler = /*#__PURE__*/function () {
113
123
  return this.active;
114
124
  }
115
125
  }]);
126
+
116
127
  return TwoTouchHandler;
117
128
  }();
129
+
118
130
  export { TwoTouchHandler as default };
131
+
119
132
  function getTouchById(mapTouches, points, identifier) {
120
133
  for (var i = 0; i < mapTouches.length; i++) {
121
134
  if (mapTouches[i].identifier === identifier) {
package/es/hash.js CHANGED
@@ -5,6 +5,7 @@ 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
+
8
9
  /*
9
10
  * Adds the map's position to its page's location hash.
10
11
  * Passed as an option to the map object.
@@ -14,26 +15,34 @@ import { throttle } from 'lodash';
14
15
  var Hash = /*#__PURE__*/function () {
15
16
  function Hash(hashName) {
16
17
  var _this = this;
18
+
17
19
  _classCallCheck(this, Hash);
20
+
18
21
  _defineProperty(this, "onHashChange", function () {
19
22
  var loc = _this.getCurrentHash();
23
+
20
24
  if (loc.length >= 3 && !loc.some(function (v) {
21
25
  return isNaN(+v);
22
26
  })) {
23
27
  var bearing = _this.map.dragRotate.isEnabled() && _this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : _this.map.getBearing();
28
+
24
29
  _this.map.jumpTo({
25
30
  center: [+loc[2], +loc[1]],
26
31
  zoom: +loc[0],
27
32
  bearing: bearing,
28
33
  pitch: +(loc[4] || 0)
29
34
  });
35
+
30
36
  return true;
31
37
  }
38
+
32
39
  return false;
33
40
  });
41
+
34
42
  _defineProperty(this, "getCurrentHash", function () {
35
43
  // Get the current hash from location, stripped from its number sign
36
44
  var hash = window.location.hash.replace('#', '');
45
+
37
46
  if (_this.hashName) {
38
47
  // Split the parameter-styled hash into parts and find the value we need
39
48
  var keyval;
@@ -46,23 +55,26 @@ var Hash = /*#__PURE__*/function () {
46
55
  });
47
56
  return (keyval ? keyval[1] || '' : '').split('/');
48
57
  }
58
+
49
59
  return hash.split('/');
50
60
  });
61
+
51
62
  _defineProperty(this, "updateHashUnthrottled", function () {
52
63
  var hash = _this.getHashString();
64
+
53
65
  try {
54
66
  window.history.replaceState(window.history.state, '', hash);
55
- } catch (SecurityError) {
56
- // IE11 does not allow this if the page is within an iframe created
67
+ } catch (SecurityError) {// IE11 does not allow this if the page is within an iframe created
57
68
  // with iframe.contentWindow.document.write(...).
58
69
  // https://github.com/mapbox/mapbox-gl-js/issues/7410
59
70
  }
60
71
  });
61
- this.hashName = hashName && encodeURIComponent(hashName);
62
72
 
63
- // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
73
+ this.hashName = hashName && encodeURIComponent(hashName); // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
74
+
64
75
  this.updateHash = throttle(this.updateHashUnthrottled, 30 * 1000 / 100);
65
76
  }
77
+
66
78
  _createClass(Hash, [{
67
79
  key: "addTo",
68
80
  value: function addTo(map) {
@@ -75,10 +87,9 @@ var Hash = /*#__PURE__*/function () {
75
87
  key: "remove",
76
88
  value: function remove() {
77
89
  $window.removeEventListener('hashchange', this.onHashChange, false);
78
- this.map.off('moveend', this.updateHash);
79
- // clearTimeout(this.updateHash());
80
-
90
+ this.map.off('moveend', this.updateHash); // clearTimeout(this.updateHash());
81
91
  // @ts-ignore
92
+
82
93
  delete this.map;
83
94
  return this;
84
95
  }
@@ -86,8 +97,8 @@ var Hash = /*#__PURE__*/function () {
86
97
  key: "getHashString",
87
98
  value: function getHashString(mapFeedback) {
88
99
  var center = this.map.getCenter();
89
- var zoom = Math.round(this.map.getZoom() * 100) / 100;
90
- // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
100
+ var zoom = Math.round(this.map.getZoom() * 100) / 100; // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
101
+
91
102
  var precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
92
103
  var m = Math.pow(10, precision);
93
104
  var lng = Math.round(center.lng * m) / m;
@@ -95,6 +106,7 @@ var Hash = /*#__PURE__*/function () {
95
106
  var bearing = this.map.getBearing();
96
107
  var pitch = this.map.getPitch();
97
108
  var hash = '';
109
+
98
110
  if (mapFeedback) {
99
111
  // new map feedback site has some constraints that don't allow
100
112
  // us to use the same hash format as we do for the Map hash option.
@@ -102,33 +114,43 @@ var Hash = /*#__PURE__*/function () {
102
114
  } else {
103
115
  hash += "".concat(zoom, "/").concat(lat, "/").concat(lng);
104
116
  }
117
+
105
118
  if (bearing || pitch) {
106
119
  hash += "/".concat(Math.round(bearing * 10) / 10);
107
120
  }
121
+
108
122
  if (pitch) {
109
123
  hash += "/".concat(Math.round(pitch));
110
124
  }
125
+
111
126
  if (this.hashName) {
112
127
  var hashName = this.hashName;
113
128
  var found = false;
114
129
  var parts = window.location.hash.slice(1).split('&').map(function (part) {
115
130
  var key = part.split('=')[0];
131
+
116
132
  if (key === hashName) {
117
133
  found = true;
118
134
  return "".concat(key, "=").concat(hash);
119
135
  }
136
+
120
137
  return part;
121
138
  }).filter(function (a) {
122
139
  return a;
123
140
  });
141
+
124
142
  if (!found) {
125
143
  parts.push("".concat(hashName, "=").concat(hash));
126
144
  }
145
+
127
146
  return "#".concat(parts.join('&'));
128
147
  }
148
+
129
149
  return "#".concat(hash);
130
150
  }
131
151
  }]);
152
+
132
153
  return Hash;
133
154
  }();
155
+
134
156
  export default Hash;
package/es/map.js CHANGED
@@ -6,45 +6,59 @@ 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
+
9
10
  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
+
10
12
  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
+
11
14
  import { $window, DOM, isMini } from '@antv/l7-utils';
12
15
  import { merge } from 'lodash';
13
16
  import Camera from "./camera";
17
+
14
18
  function loadStyles(css, doc) {
15
19
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
16
20
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
21
+
17
22
  if (isMiniAli || isWeChatMiniProgram) {
18
23
  return;
19
24
  }
25
+
20
26
  if (!doc) doc = document;
27
+
21
28
  if (!doc) {
22
29
  return;
23
30
  }
31
+
24
32
  var head = doc.head || doc.getElementsByTagName('head')[0];
33
+
25
34
  if (!head) {
26
35
  head = doc.createElement('head');
27
36
  var body = doc.body || doc.getElementsByTagName('body')[0];
37
+
28
38
  if (body) {
29
39
  body.parentNode.insertBefore(head, body);
30
40
  } else {
31
41
  doc.documentElement.appendChild(head);
32
42
  }
33
43
  }
44
+
34
45
  var style = doc.createElement('style');
35
46
  style.type = 'text/css';
47
+
36
48
  if (style.styleSheet) {
37
49
  style.styleSheet.cssText = css;
38
50
  } else {
39
51
  style.appendChild(doc.createTextNode(css));
40
52
  }
53
+
41
54
  head.appendChild(style);
42
55
  return style;
43
56
  }
57
+
44
58
  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");
45
59
  import LngLat from "./geo/lng_lat";
46
- import LngLatBounds from "./geo/lng_lat_bounds";
47
- // @ts-ignore
60
+ import LngLatBounds from "./geo/lng_lat_bounds"; // @ts-ignore
61
+
48
62
  import Point from "./geo/point";
49
63
  import HandlerManager from "./handler/handler_manager";
50
64
  import Hash from "./hash";
@@ -52,9 +66,8 @@ import { renderframe } from "./util";
52
66
  import { PerformanceUtils } from "./utils/performance";
53
67
  import TaskQueue from "./utils/task_queue";
54
68
  var defaultMinZoom = -2;
55
- var defaultMaxZoom = 22;
69
+ var defaultMaxZoom = 22; // the default values, but also the valid range
56
70
 
57
- // the default values, but also the valid range
58
71
  var defaultMinPitch = 0;
59
72
  var defaultMaxPitch = 60;
60
73
  var DefaultOptions = {
@@ -86,16 +99,24 @@ var DefaultOptions = {
86
99
  };
87
100
  export var Map = /*#__PURE__*/function (_Camera) {
88
101
  _inherits(Map, _Camera);
102
+
89
103
  var _super = _createSuper(Map);
104
+
90
105
  function Map(options) {
91
106
  var _this;
107
+
92
108
  _classCallCheck(this, Map);
109
+
93
110
  _this = _super.call(this, merge({}, DefaultOptions, options));
111
+
94
112
  _defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
113
+
95
114
  _defineProperty(_assertThisInitialized(_this), "trackResize", true);
115
+
96
116
  _defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
97
117
  _this.update();
98
118
  });
119
+
99
120
  _defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
100
121
  if (_this.trackResize) {
101
122
  _this.resize({
@@ -103,26 +124,32 @@ export var Map = /*#__PURE__*/function (_Camera) {
103
124
  }).update();
104
125
  }
105
126
  });
127
+
106
128
  if (isMini) {
107
129
  _this.initMiniContainer();
108
130
  } else {
109
131
  _this.initContainer();
110
132
  }
133
+
111
134
  _this.resize();
135
+
112
136
  _this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
137
+
113
138
  if (typeof window !== 'undefined') {
114
139
  window.addEventListener('online', _this.onWindowOnline, false);
115
140
  window.addEventListener('resize', _this.onWindowResize, false);
116
141
  window.addEventListener('orientationchange', _this.onWindowResize, false);
117
142
  }
143
+
118
144
  if (!isMini) {
119
145
  var hashName = typeof options.hash === 'string' && options.hash || undefined;
146
+
120
147
  if (options.hash) {
121
148
  _this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
122
149
  }
123
- }
150
+ } // don't set position from options if set through hash
151
+
124
152
 
125
- // don't set position from options if set through hash
126
153
  if (!_this.hash || !_this.hash.onHashChange()) {
127
154
  _this.jumpTo({
128
155
  center: options.center,
@@ -130,37 +157,47 @@ export var Map = /*#__PURE__*/function (_Camera) {
130
157
  bearing: options.bearing,
131
158
  pitch: options.pitch
132
159
  });
160
+
133
161
  if (options.bounds) {
134
162
  _this.resize();
163
+
135
164
  _this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
136
165
  duration: 0
137
166
  }));
138
167
  }
139
168
  }
169
+
140
170
  return _this;
141
171
  }
172
+
142
173
  _createClass(Map, [{
143
174
  key: "resize",
144
175
  value: function resize(eventData) {
145
176
  var _this$containerDimens = this.containerDimensions(),
146
- _this$containerDimens2 = _slicedToArray(_this$containerDimens, 2),
147
- width = _this$containerDimens2[0],
148
- height = _this$containerDimens2[1];
149
- this.transform.resize(width, height);
150
- // 小程序环境不需要执行后续动作
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
+
151
183
  if (isMini) {
152
184
  return this;
153
185
  }
186
+
154
187
  var fireMoving = !this.moving;
188
+
155
189
  if (fireMoving) {
156
190
  this.stop();
157
191
  this.emit('movestart', new $window.Event('movestart', eventData));
158
192
  this.emit('move', new $window.Event('move', eventData));
159
193
  }
194
+
160
195
  this.emit('resize', new $window.Event('resize', eventData));
196
+
161
197
  if (fireMoving) {
162
198
  this.emit('moveend', new $window.Event('moveend', eventData));
163
199
  }
200
+
164
201
  return this;
165
202
  }
166
203
  }, {
@@ -202,9 +239,8 @@ export var Map = /*#__PURE__*/function (_Camera) {
202
239
  key: "setMaxBounds",
203
240
  value: function setMaxBounds(bounds) {
204
241
  this.transform.setMaxBounds(LngLatBounds.convert(bounds));
205
- }
242
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
206
243
 
207
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
208
244
  }, {
209
245
  key: "setStyle",
210
246
  value: function setStyle(style) {
@@ -214,11 +250,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
214
250
  key: "setMinZoom",
215
251
  value: function setMinZoom(minZoom) {
216
252
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
253
+
217
254
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
218
255
  this.transform.minZoom = minZoom;
256
+
219
257
  if (this.getZoom() < minZoom) {
220
258
  this.setZoom(minZoom);
221
259
  }
260
+
222
261
  return this;
223
262
  } else {
224
263
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -233,11 +272,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
233
272
  key: "setMaxZoom",
234
273
  value: function setMaxZoom(maxZoom) {
235
274
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
275
+
236
276
  if (maxZoom >= this.transform.minZoom) {
237
277
  this.transform.maxZoom = maxZoom;
278
+
238
279
  if (this.getZoom() > maxZoom) {
239
280
  this.setZoom(maxZoom);
240
281
  }
282
+
241
283
  return this;
242
284
  } else {
243
285
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -252,14 +294,18 @@ export var Map = /*#__PURE__*/function (_Camera) {
252
294
  key: "setMinPitch",
253
295
  value: function setMinPitch(minPitch) {
254
296
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
297
+
255
298
  if (minPitch < defaultMinPitch) {
256
299
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
257
300
  }
301
+
258
302
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
259
303
  this.transform.minPitch = minPitch;
304
+
260
305
  if (this.getPitch() < minPitch) {
261
306
  this.setPitch(minPitch);
262
307
  }
308
+
263
309
  return this;
264
310
  } else {
265
311
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -274,14 +320,18 @@ export var Map = /*#__PURE__*/function (_Camera) {
274
320
  key: "setMaxPitch",
275
321
  value: function setMaxPitch(maxPitch) {
276
322
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
323
+
277
324
  if (maxPitch > defaultMaxPitch) {
278
325
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
279
326
  }
327
+
280
328
  if (maxPitch >= this.transform.minPitch) {
281
329
  this.transform.maxPitch = maxPitch;
330
+
282
331
  if (this.getPitch() > maxPitch) {
283
332
  this.setPitch(maxPitch);
284
333
  }
334
+
285
335
  return this;
286
336
  } else {
287
337
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -305,13 +355,15 @@ export var Map = /*#__PURE__*/function (_Camera) {
305
355
  }, {
306
356
  key: "remove",
307
357
  value: function remove() {
308
- this.container.removeChild(this.canvasContainer);
309
- // @ts-ignore
358
+ this.container.removeChild(this.canvasContainer); // @ts-ignore
359
+
310
360
  this.canvasContainer = null;
361
+
311
362
  if (this.frame) {
312
363
  this.frame.cancel();
313
364
  this.frame = null;
314
365
  }
366
+
315
367
  this.renderTaskQueue.clear();
316
368
  }
317
369
  }, {
@@ -329,10 +381,12 @@ export var Map = /*#__PURE__*/function (_Camera) {
329
381
  key: "triggerRepaint",
330
382
  value: function triggerRepaint() {
331
383
  var _this2 = this;
384
+
332
385
  if (!this.frame) {
333
386
  this.frame = renderframe(function (paintStartTimeStamp) {
334
387
  PerformanceUtils.frame(paintStartTimeStamp);
335
388
  _this2.frame = null;
389
+
336
390
  _this2.update(paintStartTimeStamp);
337
391
  });
338
392
  }
@@ -341,10 +395,12 @@ export var Map = /*#__PURE__*/function (_Camera) {
341
395
  key: "update",
342
396
  value: function update(time) {
343
397
  var _this3 = this;
398
+
344
399
  if (!this.frame) {
345
400
  this.frame = renderframe(function (paintStartTimeStamp) {
346
401
  PerformanceUtils.frame(paintStartTimeStamp);
347
402
  _this3.frame = null;
403
+
348
404
  _this3.renderTaskQueue.run(time);
349
405
  });
350
406
  }
@@ -354,6 +410,7 @@ export var Map = /*#__PURE__*/function (_Camera) {
354
410
  value: function initContainer() {
355
411
  if (typeof this.options.container === 'string') {
356
412
  this.container = window.document.getElementById(this.options.container);
413
+
357
414
  if (!this.container) {
358
415
  throw new Error("Container '".concat(this.options.container, "' not found."));
359
416
  }
@@ -362,17 +419,19 @@ export var Map = /*#__PURE__*/function (_Camera) {
362
419
  } else {
363
420
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
364
421
  }
422
+
365
423
  var container = this.container;
366
424
  container.classList.add('l7-map');
367
425
  var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
426
+
368
427
  if (this.options.interactive) {
369
428
  canvasContainer.classList.add('l7-interactive');
370
429
  }
371
430
  }
372
-
373
431
  /**
374
432
  * 小程序环境构建容器
375
433
  */
434
+
376
435
  }, {
377
436
  key: "initMiniContainer",
378
437
  value: function initMiniContainer() {
@@ -384,6 +443,7 @@ export var Map = /*#__PURE__*/function (_Camera) {
384
443
  value: function containerDimensions() {
385
444
  var width = 0;
386
445
  var height = 0;
446
+
387
447
  if (this.container) {
388
448
  if (isMini) {
389
449
  width = this.container.width / $window.devicePixelRatio;
@@ -395,8 +455,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
395
455
  height = height === 0 ? 300 : height;
396
456
  }
397
457
  }
458
+
398
459
  return [width, height];
399
460
  }
400
461
  }]);
462
+
401
463
  return Map;
402
464
  }(Camera);