@antv/l7-map 2.25.5 → 2.25.7

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 (159) hide show
  1. package/package.json +2 -2
  2. package/es/index.d.ts +0 -5
  3. package/es/index.js +0 -4
  4. package/es/map/camera.d.ts +0 -690
  5. package/es/map/camera.js +0 -1138
  6. package/es/map/css/l7.css +0 -171
  7. package/es/map/events.d.ts +0 -384
  8. package/es/map/events.js +0 -231
  9. package/es/map/geo/edge_insets.d.ts +0 -97
  10. package/es/map/geo/edge_insets.js +0 -115
  11. package/es/map/geo/lng_lat.d.ts +0 -116
  12. package/es/map/geo/lng_lat.js +0 -159
  13. package/es/map/geo/lng_lat_bounds.d.ts +0 -217
  14. package/es/map/geo/lng_lat_bounds.js +0 -334
  15. package/es/map/geo/mercator_coordinate.d.ts +0 -113
  16. package/es/map/geo/mercator_coordinate.js +0 -142
  17. package/es/map/geo/transform.d.ts +0 -262
  18. package/es/map/geo/transform.js +0 -736
  19. package/es/map/handler/box_zoom.d.ts +0 -65
  20. package/es/map/handler/box_zoom.js +0 -145
  21. package/es/map/handler/click_zoom.d.ts +0 -24
  22. package/es/map/handler/click_zoom.js +0 -47
  23. package/es/map/handler/cooperative_gestures.d.ts +0 -40
  24. package/es/map/handler/cooperative_gestures.js +0 -94
  25. package/es/map/handler/drag_handler.d.ts +0 -88
  26. package/es/map/handler/drag_handler.js +0 -89
  27. package/es/map/handler/drag_move_state_manager.d.ts +0 -30
  28. package/es/map/handler/drag_move_state_manager.js +0 -94
  29. package/es/map/handler/handler_util.d.ts +0 -3
  30. package/es/map/handler/handler_util.js +0 -8
  31. package/es/map/handler/keyboard.d.ts +0 -88
  32. package/es/map/handler/keyboard.js +0 -197
  33. package/es/map/handler/map_event.d.ts +0 -46
  34. package/es/map/handler/map_event.js +0 -131
  35. package/es/map/handler/mouse.d.ts +0 -30
  36. package/es/map/handler/mouse.js +0 -85
  37. package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
  38. package/es/map/handler/one_finger_touch_drag.js +0 -39
  39. package/es/map/handler/scroll_zoom.d.ts +0 -102
  40. package/es/map/handler/scroll_zoom.js +0 -312
  41. package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
  42. package/es/map/handler/shim/dblclick_zoom.js +0 -60
  43. package/es/map/handler/shim/drag_pan.d.ts +0 -79
  44. package/es/map/handler/shim/drag_pan.js +0 -77
  45. package/es/map/handler/shim/drag_rotate.d.ts +0 -54
  46. package/es/map/handler/shim/drag_rotate.js +0 -66
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
  48. package/es/map/handler/shim/two_fingers_touch.js +0 -106
  49. package/es/map/handler/tap_drag_zoom.d.ts +0 -28
  50. package/es/map/handler/tap_drag_zoom.js +0 -92
  51. package/es/map/handler/tap_recognizer.d.ts +0 -35
  52. package/es/map/handler/tap_recognizer.js +0 -107
  53. package/es/map/handler/tap_zoom.d.ts +0 -28
  54. package/es/map/handler/tap_zoom.js +0 -87
  55. package/es/map/handler/touch_pan.d.ts +0 -40
  56. package/es/map/handler/touch_pan.js +0 -85
  57. package/es/map/handler/transform-provider.d.ts +0 -23
  58. package/es/map/handler/transform-provider.js +0 -35
  59. package/es/map/handler/two_fingers_touch.d.ts +0 -107
  60. package/es/map/handler/two_fingers_touch.js +0 -289
  61. package/es/map/handler_inertia.d.ts +0 -20
  62. package/es/map/handler_inertia.js +0 -128
  63. package/es/map/handler_manager.d.ts +0 -154
  64. package/es/map/handler_manager.js +0 -466
  65. package/es/map/map.d.ts +0 -637
  66. package/es/map/map.js +0 -984
  67. package/es/map/util/abort_error.d.ts +0 -15
  68. package/es/map/util/abort_error.js +0 -21
  69. package/es/map/util/browser.d.ts +0 -10
  70. package/es/map/util/browser.js +0 -30
  71. package/es/map/util/dom.d.ts +0 -30
  72. package/es/map/util/dom.js +0 -105
  73. package/es/map/util/evented.d.ts +0 -75
  74. package/es/map/util/evented.js +0 -158
  75. package/es/map/util/simpleMapCoord.d.ts +0 -31
  76. package/es/map/util/simpleMapCoord.js +0 -54
  77. package/es/map/util/task_queue.d.ts +0 -18
  78. package/es/map/util/task_queue.js +0 -54
  79. package/es/map/util/util.d.ts +0 -104
  80. package/es/map/util/util.js +0 -155
  81. package/lib/index.d.ts +0 -5
  82. package/lib/index.js +0 -33
  83. package/lib/map/camera.d.ts +0 -690
  84. package/lib/map/camera.js +0 -1145
  85. package/lib/map/css/l7.css +0 -171
  86. package/lib/map/events.d.ts +0 -384
  87. package/lib/map/events.js +0 -240
  88. package/lib/map/geo/edge_insets.d.ts +0 -97
  89. package/lib/map/geo/edge_insets.js +0 -122
  90. package/lib/map/geo/lng_lat.d.ts +0 -116
  91. package/lib/map/geo/lng_lat.js +0 -166
  92. package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
  93. package/lib/map/geo/lng_lat_bounds.js +0 -341
  94. package/lib/map/geo/mercator_coordinate.d.ts +0 -113
  95. package/lib/map/geo/mercator_coordinate.js +0 -157
  96. package/lib/map/geo/transform.d.ts +0 -262
  97. package/lib/map/geo/transform.js +0 -744
  98. package/lib/map/handler/box_zoom.d.ts +0 -65
  99. package/lib/map/handler/box_zoom.js +0 -153
  100. package/lib/map/handler/click_zoom.d.ts +0 -24
  101. package/lib/map/handler/click_zoom.js +0 -54
  102. package/lib/map/handler/cooperative_gestures.d.ts +0 -40
  103. package/lib/map/handler/cooperative_gestures.js +0 -101
  104. package/lib/map/handler/drag_handler.d.ts +0 -88
  105. package/lib/map/handler/drag_handler.js +0 -97
  106. package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
  107. package/lib/map/handler/drag_move_state_manager.js +0 -103
  108. package/lib/map/handler/handler_util.d.ts +0 -3
  109. package/lib/map/handler/handler_util.js +0 -14
  110. package/lib/map/handler/keyboard.d.ts +0 -88
  111. package/lib/map/handler/keyboard.js +0 -205
  112. package/lib/map/handler/map_event.d.ts +0 -46
  113. package/lib/map/handler/map_event.js +0 -140
  114. package/lib/map/handler/mouse.d.ts +0 -30
  115. package/lib/map/handler/mouse.js +0 -93
  116. package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
  117. package/lib/map/handler/one_finger_touch_drag.js +0 -47
  118. package/lib/map/handler/scroll_zoom.d.ts +0 -102
  119. package/lib/map/handler/scroll_zoom.js +0 -320
  120. package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
  121. package/lib/map/handler/shim/dblclick_zoom.js +0 -68
  122. package/lib/map/handler/shim/drag_pan.d.ts +0 -79
  123. package/lib/map/handler/shim/drag_pan.js +0 -85
  124. package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
  125. package/lib/map/handler/shim/drag_rotate.js +0 -74
  126. package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
  127. package/lib/map/handler/shim/two_fingers_touch.js +0 -114
  128. package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
  129. package/lib/map/handler/tap_drag_zoom.js +0 -99
  130. package/lib/map/handler/tap_recognizer.d.ts +0 -35
  131. package/lib/map/handler/tap_recognizer.js +0 -116
  132. package/lib/map/handler/tap_zoom.d.ts +0 -28
  133. package/lib/map/handler/tap_zoom.js +0 -94
  134. package/lib/map/handler/touch_pan.d.ts +0 -40
  135. package/lib/map/handler/touch_pan.js +0 -92
  136. package/lib/map/handler/transform-provider.d.ts +0 -23
  137. package/lib/map/handler/transform-provider.js +0 -43
  138. package/lib/map/handler/two_fingers_touch.d.ts +0 -107
  139. package/lib/map/handler/two_fingers_touch.js +0 -296
  140. package/lib/map/handler_inertia.d.ts +0 -20
  141. package/lib/map/handler_inertia.js +0 -136
  142. package/lib/map/handler_manager.d.ts +0 -154
  143. package/lib/map/handler_manager.js +0 -474
  144. package/lib/map/map.d.ts +0 -637
  145. package/lib/map/map.js +0 -991
  146. package/lib/map/util/abort_error.d.ts +0 -15
  147. package/lib/map/util/abort_error.js +0 -29
  148. package/lib/map/util/browser.d.ts +0 -10
  149. package/lib/map/util/browser.js +0 -36
  150. package/lib/map/util/dom.d.ts +0 -30
  151. package/lib/map/util/dom.js +0 -113
  152. package/lib/map/util/evented.d.ts +0 -75
  153. package/lib/map/util/evented.js +0 -167
  154. package/lib/map/util/simpleMapCoord.d.ts +0 -31
  155. package/lib/map/util/simpleMapCoord.js +0 -62
  156. package/lib/map/util/task_queue.d.ts +0 -18
  157. package/lib/map/util/task_queue.js +0 -62
  158. package/lib/map/util/util.d.ts +0 -104
  159. package/lib/map/util/util.js +0 -171
package/lib/map/map.js DELETED
@@ -1,991 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Map = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
11
- var _camera = require("./camera");
12
- var _lng_lat = require("./geo/lng_lat");
13
- var _lng_lat_bounds = require("./geo/lng_lat_bounds");
14
- var _transform = require("./geo/transform");
15
- var _handler_manager = require("./handler_manager");
16
- var _browser = require("./util/browser");
17
- var _dom = require("./util/dom");
18
- var _evented = require("./util/evented");
19
- var _task_queue = require("./util/task_queue");
20
- var _util = require("./util/util");
21
- var _l7Utils = require("@antv/l7-utils");
22
- function loadStyles(css, doc) {
23
- var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
24
- var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
25
- if (isMiniAli || isWeChatMiniProgram) {
26
- return;
27
- }
28
- if (!doc) doc = document;
29
- if (!doc) {
30
- return;
31
- }
32
- var head = doc.head || doc.getElementsByTagName('head')[0];
33
- if (!head) {
34
- head = doc.createElement('head');
35
- var body = doc.body || doc.getElementsByTagName('body')[0];
36
- if (body) {
37
- body.parentNode.insertBefore(head, body);
38
- } else {
39
- doc.documentElement.appendChild(head);
40
- }
41
- }
42
- var style = doc.createElement('style');
43
- style.type = 'text/css';
44
- if (style.styleSheet) {
45
- style.styleSheet.cssText = css;
46
- } else {
47
- style.appendChild(doc.createTextNode(css));
48
- }
49
- head.appendChild(style);
50
- return style;
51
- }
52
- loadStyles(`.l7-map {
53
- font:
54
- 12px/20px 'Helvetica Neue',
55
- Arial,
56
- Helvetica,
57
- sans-serif;
58
- overflow: hidden;
59
- position: relative;
60
- -webkit-tap-highlight-color: rgb(0 0 0 / 0%);
61
- }
62
-
63
- .l7-canvas {
64
- position: absolute;
65
- left: 0;
66
- top: 0;
67
- }
68
-
69
- .l7-map:full-screen {
70
- width: 100%;
71
- height: 100%;
72
- }
73
-
74
- .l7-canary {
75
- background-color: salmon;
76
- }
77
-
78
- .l7-canvas-container.l7-interactive,
79
- .l7-ctrl-group button.l7-ctrl-compass {
80
- cursor: grab;
81
- -webkit-user-select: none;
82
- -moz-user-select: none;
83
- -ms-user-select: none;
84
- user-select: none;
85
- }
86
-
87
- .l7-canvas-container.l7-interactive.l7-track-pointer {
88
- cursor: pointer;
89
- }
90
-
91
- .l7-canvas-container.l7-interactive:active,
92
- .l7-ctrl-group button.l7-ctrl-compass:active {
93
- cursor: grabbing;
94
- }
95
-
96
- .l7-canvas-container.l7-touch-zoom-rotate,
97
- .l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
98
- touch-action: pan-x pan-y;
99
- }
100
-
101
- .l7-canvas-container.l7-touch-drag-pan,
102
- .l7-canvas-container.l7-touch-drag-pan .l7-canvas {
103
- touch-action: pinch-zoom;
104
- }
105
-
106
- .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
107
- .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
108
- touch-action: none;
109
- }
110
-
111
- .l7-canvas-container.l7-touch-drag-pan.l7-cooperative-gestures,
112
- .l7-canvas-container.l7-touch-drag-pan.l7-cooperative-gestures .l7-canvas {
113
- touch-action: pan-x pan-y;
114
- }
115
-
116
- .l7-cooperative-gesture-screen {
117
- background: rgba(0 0 0 / 40%);
118
- position: absolute;
119
- inset: 0;
120
- display: flex;
121
- justify-content: center;
122
- align-items: center;
123
- color: white;
124
- padding: 1rem;
125
- font-size: 1.4em;
126
- line-height: 1.2;
127
- opacity: 0;
128
- pointer-events: none;
129
- transition: opacity 1s ease 1s;
130
- z-index: 99999;
131
- }
132
-
133
- .l7-cooperative-gesture-screen.l7-show {
134
- opacity: 1;
135
- transition: opacity 0.05s;
136
- }
137
-
138
- .l7-cooperative-gesture-screen .l7-mobile-message {
139
- display: none;
140
- }
141
-
142
- @media (hover: none), (width <= 480px) {
143
- .l7-cooperative-gesture-screen .l7-desktop-message {
144
- display: none;
145
- }
146
-
147
- .l7-cooperative-gesture-screen .l7-mobile-message {
148
- display: block;
149
- }
150
- }
151
-
152
- .l7-ctrl-top-left,
153
- .l7-ctrl-top-right,
154
- .l7-ctrl-bottom-left,
155
- .l7-ctrl-bottom-right {
156
- position: absolute;
157
- pointer-events: none;
158
- z-index: 2;
159
- }
160
-
161
- .l7-ctrl-top-left {
162
- top: 0;
163
- left: 0;
164
- }
165
-
166
- .l7-ctrl-top-right {
167
- top: 0;
168
- right: 0;
169
- }
170
-
171
- .l7-ctrl-bottom-left {
172
- bottom: 0;
173
- left: 0;
174
- }
175
-
176
- .l7-ctrl-bottom-right {
177
- right: 0;
178
- bottom: 0;
179
- }
180
-
181
- .l7-ctrl {
182
- clear: both;
183
- pointer-events: auto;
184
-
185
- /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
186
- -webkit-transform: translate(0, 0);
187
- transform: translate(0, 0);
188
- }
189
-
190
- .l7-ctrl-top-left .l7-ctrl {
191
- margin: 10px 0 0 10px;
192
- float: left;
193
- }
194
-
195
- .l7-ctrl-top-right .l7-ctrl {
196
- margin: 10px 10px 0 0;
197
- float: right;
198
- }
199
-
200
- .l7-ctrl-bottom-left .l7-ctrl {
201
- margin: 0 0 10px 10px;
202
- float: left;
203
- }
204
-
205
- .l7-ctrl-bottom-right .l7-ctrl {
206
- margin: 0 10px 10px 0;
207
- float: right;
208
- }
209
-
210
- .l7-crosshair,
211
- .l7-crosshair .l7-interactive,
212
- .l7-crosshair .l7-interactive:active {
213
- cursor: crosshair;
214
- }
215
-
216
- .l7-boxzoom {
217
- position: absolute;
218
- top: 0;
219
- left: 0;
220
- width: 0;
221
- height: 0;
222
- background: #fff;
223
- border: 2px dotted #202020;
224
- opacity: 0.5;
225
- z-index: 10;
226
- }
227
- `);
228
- /**
229
- * The {@link Map} options object.
230
- */
231
-
232
- // This type is used inside map since all properties are assigned a default value.
233
-
234
- const defaultMinZoom = -2;
235
- const defaultMaxZoom = 22;
236
-
237
- // the default values, but also the valid range
238
- const defaultMinPitch = 0;
239
- const defaultMaxPitch = 60;
240
-
241
- // use this variable to check maxPitch for validity
242
- const maxPitchThreshold = 85;
243
- const defaultOptions = {
244
- interactive: true,
245
- bearingSnap: 7,
246
- scrollZoom: true,
247
- minZoom: defaultMinZoom,
248
- maxZoom: defaultMaxZoom,
249
- minPitch: defaultMinPitch,
250
- maxPitch: defaultMaxPitch,
251
- boxZoom: true,
252
- dragRotate: true,
253
- dragPan: true,
254
- keyboard: true,
255
- doubleClickZoom: true,
256
- touchZoomRotate: true,
257
- touchPitch: true,
258
- cooperativeGestures: false,
259
- trackResize: true,
260
- center: [0, 0],
261
- zoom: 0,
262
- bearing: 0,
263
- pitch: 0,
264
- renderWorldCopies: true,
265
- fadeDuration: 300,
266
- clickTolerance: 3,
267
- pitchWithRotate: true
268
- };
269
-
270
- /**
271
- * The `Map` object represents the map on your page. It exposes methods
272
- * and properties that enable you to programmatically change the map,
273
- * and fires events as users interact with it.
274
- *
275
- * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list.
276
- * Then MapLibre GL JS initializes the map on the page and returns your `Map` object.
277
- *
278
- * @group Main
279
- *
280
- * @example
281
- * ```ts
282
- * let map = new Map({
283
- * container: 'map',
284
- * center: [-122.420679, 37.772537],
285
- * zoom: 13,
286
- * });
287
- * ```
288
- */
289
- class Map extends _camera.Camera {
290
- constructor(options) {
291
- const resolvedOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultOptions), options);
292
- if (resolvedOptions.minZoom != null && resolvedOptions.maxZoom != null && resolvedOptions.minZoom > resolvedOptions.maxZoom) {
293
- throw new Error('maxZoom must be greater than or equal to minZoom');
294
- }
295
- if (resolvedOptions.minPitch != null && resolvedOptions.maxPitch != null && resolvedOptions.minPitch > resolvedOptions.maxPitch) {
296
- throw new Error('maxPitch must be greater than or equal to minPitch');
297
- }
298
- if (resolvedOptions.minPitch != null && resolvedOptions.minPitch < defaultMinPitch) {
299
- throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
300
- }
301
- if (resolvedOptions.maxPitch != null && resolvedOptions.maxPitch > maxPitchThreshold) {
302
- throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);
303
- }
304
- const transform = new _transform.Transform(resolvedOptions.minZoom, resolvedOptions.maxZoom, resolvedOptions.minPitch, resolvedOptions.maxPitch, resolvedOptions.renderWorldCopies);
305
- super(transform, {
306
- bearingSnap: resolvedOptions.bearingSnap
307
- });
308
- (0, _defineProperty2.default)(this, "_container", void 0);
309
- (0, _defineProperty2.default)(this, "_canvasContainer", void 0);
310
- (0, _defineProperty2.default)(this, "_interactive", void 0);
311
- (0, _defineProperty2.default)(this, "_frameRequest", void 0);
312
- (0, _defineProperty2.default)(this, "_loaded", void 0);
313
- (0, _defineProperty2.default)(this, "_idleTriggered", false);
314
- // accounts for placement finishing as well
315
- (0, _defineProperty2.default)(this, "_fullyLoaded", void 0);
316
- (0, _defineProperty2.default)(this, "_trackResize", void 0);
317
- (0, _defineProperty2.default)(this, "_resizeObserver", void 0);
318
- (0, _defineProperty2.default)(this, "_preserveDrawingBuffer", void 0);
319
- (0, _defineProperty2.default)(this, "_failIfMajorPerformanceCaveat", void 0);
320
- (0, _defineProperty2.default)(this, "_fadeDuration", void 0);
321
- (0, _defineProperty2.default)(this, "_crossSourceCollisions", void 0);
322
- (0, _defineProperty2.default)(this, "_crossFadingFactor", 1);
323
- (0, _defineProperty2.default)(this, "_collectResourceTiming", void 0);
324
- (0, _defineProperty2.default)(this, "_renderTaskQueue", new _task_queue.TaskQueue());
325
- (0, _defineProperty2.default)(this, "_mapId", (0, _util.uniqueId)());
326
- (0, _defineProperty2.default)(this, "_removed", void 0);
327
- (0, _defineProperty2.default)(this, "_clickTolerance", void 0);
328
- (0, _defineProperty2.default)(this, "version", void 0);
329
- (0, _defineProperty2.default)(this, "mapSize", void 0);
330
- /**
331
- * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
332
- * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
333
- */
334
- (0, _defineProperty2.default)(this, "scrollZoom", void 0);
335
- /**
336
- * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed.
337
- * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section.
338
- */
339
- (0, _defineProperty2.default)(this, "boxZoom", void 0);
340
- /**
341
- * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right
342
- * mouse button or with the Control key pressed. Find more details and examples using `dragRotate`
343
- * in the {@link DragRotateHandler} section.
344
- */
345
- (0, _defineProperty2.default)(this, "dragRotate", void 0);
346
- /**
347
- * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture.
348
- * Find more details and examples using `dragPan` in the {@link DragPanHandler} section.
349
- */
350
- (0, _defineProperty2.default)(this, "dragPan", void 0);
351
- /**
352
- * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard
353
- * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section.
354
- */
355
- (0, _defineProperty2.default)(this, "keyboard", void 0);
356
- /**
357
- * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking.
358
- * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section.
359
- */
360
- (0, _defineProperty2.default)(this, "doubleClickZoom", void 0);
361
- /**
362
- * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures.
363
- * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section.
364
- */
365
- (0, _defineProperty2.default)(this, "touchZoomRotate", void 0);
366
- /**
367
- * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures.
368
- * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section.
369
- */
370
- (0, _defineProperty2.default)(this, "touchPitch", void 0);
371
- /**
372
- * The map's {@link CooperativeGesturesHandler}, which allows the user to see cooperative gesture info when user tries to zoom in/out.
373
- * Find more details and examples using `cooperativeGestures` in the {@link CooperativeGesturesHandler} section.
374
- */
375
- (0, _defineProperty2.default)(this, "cooperativeGestures", void 0);
376
- (0, _defineProperty2.default)(this, "_onMapScroll", event => {
377
- if (event.target !== this._container) return;
378
-
379
- // Revert any scroll which would move the canvas outside of the view
380
- this._container.scrollTop = 0;
381
- this._container.scrollLeft = 0;
382
- return false;
383
- });
384
- this._interactive = resolvedOptions.interactive;
385
- this._trackResize = resolvedOptions.trackResize === true;
386
- this._bearingSnap = resolvedOptions.bearingSnap;
387
- this._fadeDuration = resolvedOptions.fadeDuration;
388
- this._clickTolerance = resolvedOptions.clickTolerance;
389
- this.version = options.version;
390
- this.mapSize = options.mapSize;
391
- if (typeof resolvedOptions.container === 'string') {
392
- this._container = document.getElementById(resolvedOptions.container);
393
- if (!this._container) {
394
- throw new Error(`Container '${resolvedOptions.container}' not found.`);
395
- }
396
- } else if (resolvedOptions.container instanceof HTMLElement) {
397
- this._container = resolvedOptions.container;
398
- } else {
399
- throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
400
- }
401
- if (resolvedOptions.maxBounds) {
402
- this.setMaxBounds(resolvedOptions.maxBounds);
403
- }
404
- this._setupContainer();
405
- this.on('move', () => this._update()).on('moveend', () => this._update()).on('zoom', () => this._update()).once('idle', () => {
406
- this._idleTriggered = true;
407
- });
408
- if (typeof window !== 'undefined') {
409
- let initialResizeEventCaptured = false;
410
- const throttledResizeCallback = _l7Utils.lodashUtil.throttle(entries => {
411
- if (this._trackResize && !this._removed) {
412
- this.resize(entries)._update();
413
- }
414
- }, 50);
415
- this._resizeObserver = new ResizeObserver(entries => {
416
- if (!initialResizeEventCaptured) {
417
- initialResizeEventCaptured = true;
418
- return;
419
- }
420
- throttledResizeCallback(entries);
421
- });
422
- this._resizeObserver.observe(this._container);
423
- }
424
- this.handlers = new _handler_manager.HandlerManager(this, resolvedOptions);
425
- this.jumpTo({
426
- center: resolvedOptions.center,
427
- zoom: resolvedOptions.zoom,
428
- bearing: resolvedOptions.bearing,
429
- pitch: resolvedOptions.pitch
430
- });
431
- if (resolvedOptions.bounds) {
432
- this.resize();
433
- this.fitBounds(resolvedOptions.bounds, (0, _util.extend)({}, resolvedOptions.fitBoundsOptions, {
434
- duration: 0
435
- }));
436
- }
437
- this.resize();
438
- }
439
-
440
- /**
441
- * @internal
442
- * Returns a unique number for this map instance which is used for the MapLoadEvent
443
- * to make sure we only fire one event per instantiated map object.
444
- * @returns the uniq map ID
445
- */
446
- _getMapId() {
447
- return this._mapId;
448
- }
449
- calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo) {
450
- return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);
451
- }
452
-
453
- /**
454
- * Resizes the map according to the dimensions of its
455
- * `container` element.
456
- *
457
- * Checks if the map container size changed and updates the map if it has changed.
458
- * This method must be called after the map's `container` is resized programmatically
459
- * or when the map is shown after being initially hidden with CSS.
460
- *
461
- * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.
462
- *
463
- * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`
464
- * events that get triggered as a result of resize. This can be useful for differentiating the
465
- * source of an event (for example, user-initiated or programmatically-triggered events).
466
- * @example
467
- * Resize the map when the map container is shown after being initially hidden with CSS.
468
- * ```ts
469
- * let mapDiv = document.getElementById('map');
470
- * if (mapDiv.style.visibility === true) map.resize();
471
- * ```
472
- */
473
- resize(eventData) {
474
- var _this$_requestedCamer;
475
- const dimensions = this._containerDimensions();
476
- const width = dimensions[0];
477
- const height = dimensions[1];
478
- this.transform.resize(width, height);
479
- (_this$_requestedCamer = this._requestedCameraState) === null || _this$_requestedCamer === void 0 || _this$_requestedCamer.resize(width, height);
480
- const fireMoving = !this._moving;
481
- if (fireMoving) {
482
- this.stop();
483
- this.fire(new _evented.Event('movestart', eventData)).fire(new _evented.Event('move', eventData));
484
- }
485
- this.fire(new _evented.Event('resize', eventData));
486
- if (fireMoving) this.fire(new _evented.Event('moveend', eventData));
487
- return this;
488
- }
489
-
490
- /**
491
- * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not
492
- * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.
493
- * @returns The geographical bounds of the map as {@link LngLatBounds}.
494
- * @example
495
- * ```ts
496
- * let bounds = map.getBounds();
497
- * ```
498
- */
499
- getBounds() {
500
- return this.transform.getBounds();
501
- }
502
-
503
- /**
504
- * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.
505
- * @returns The map object.
506
- * @example
507
- * ```ts
508
- * let maxBounds = map.getMaxBounds();
509
- * ```
510
- */
511
- getMaxBounds() {
512
- return this.transform.getMaxBounds();
513
- }
514
-
515
- /**
516
- * Sets or clears the map's geographical bounds.
517
- *
518
- * Pan and zoom operations are constrained within these bounds.
519
- * If a pan or zoom is performed that would
520
- * display regions outside these bounds, the map will
521
- * instead display a position and zoom level
522
- * as close as possible to the operation's request while still
523
- * remaining within the bounds.
524
- *
525
- * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.
526
- * @example
527
- * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds.
528
- * ```ts
529
- * let bounds = [
530
- * [-74.04728, 40.68392], // [west, south]
531
- * [-73.91058, 40.87764] // [east, north]
532
- * ];
533
- * map.setMaxBounds(bounds);
534
- * ```
535
- */
536
- setMaxBounds(bounds) {
537
- this.transform.setMaxBounds(bounds && _lng_lat_bounds.LngLatBounds.convert(bounds));
538
- return this._update();
539
- }
540
-
541
- /**
542
- * Sets or clears the map's minimum zoom level.
543
- * If the map's current zoom level is lower than the new minimum,
544
- * the map will zoom to the new minimum.
545
- *
546
- * It is not always possible to zoom out and reach the set `minZoom`.
547
- * Other factors such as map height may restrict zooming. For example,
548
- * if the map is 512px tall it will not be possible to zoom below zoom 0
549
- * no matter what the `minZoom` is set to.
550
- *
551
- * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
552
- *
553
- * @param minZoom - The minimum zoom level to set (-2 - 24).
554
- * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).
555
- * @example
556
- * ```ts
557
- * map.setMinZoom(12.25);
558
- * ```
559
- */
560
- setMinZoom(minZoom) {
561
- minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
562
- if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
563
- this.transform.minZoom = minZoom;
564
- this._update();
565
- if (this.getZoom() < minZoom) this.setZoom(minZoom);
566
- return this;
567
- } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
568
- }
569
-
570
- /**
571
- * Returns the map's minimum allowable zoom level.
572
- *
573
- * @returns minZoom
574
- * @example
575
- * ```ts
576
- * let minZoom = map.getMinZoom();
577
- * ```
578
- */
579
- getMinZoom() {
580
- return this.transform.minZoom;
581
- }
582
-
583
- /**
584
- * Sets or clears the map's maximum zoom level.
585
- * If the map's current zoom level is higher than the new maximum,
586
- * the map will zoom to the new maximum.
587
- *
588
- * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
589
- *
590
- * @param maxZoom - The maximum zoom level to set.
591
- * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).
592
- * @example
593
- * ```ts
594
- * map.setMaxZoom(18.75);
595
- * ```
596
- */
597
- setMaxZoom(maxZoom) {
598
- maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
599
- if (maxZoom >= this.transform.minZoom) {
600
- this.transform.maxZoom = maxZoom;
601
- if (this.getZoom() > maxZoom) this.setZoom(maxZoom);
602
- return this;
603
- } else throw new Error('maxZoom must be greater than the current minZoom');
604
- }
605
-
606
- /**
607
- * Returns the map's maximum allowable zoom level.
608
- *
609
- * @returns The maxZoom
610
- * @example
611
- * ```ts
612
- * let maxZoom = map.getMaxZoom();
613
- * ```
614
- */
615
- getMaxZoom() {
616
- return this.transform.maxZoom;
617
- }
618
-
619
- /**
620
- * Sets or clears the map's minimum pitch.
621
- * If the map's current pitch is lower than the new minimum,
622
- * the map will pitch to the new minimum.
623
- *
624
- * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.
625
- *
626
- * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
627
- * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).
628
- */
629
- setMinPitch(minPitch) {
630
- minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
631
- if (minPitch < defaultMinPitch) {
632
- throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
633
- }
634
- if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
635
- this.transform.minPitch = minPitch;
636
- if (this.getPitch() < minPitch) this.setPitch(minPitch);
637
- return this;
638
- } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
639
- }
640
-
641
- /**
642
- * Returns the map's minimum allowable pitch.
643
- *
644
- * @returns The minPitch
645
- */
646
- getMinPitch() {
647
- return this.transform.minPitch;
648
- }
649
-
650
- /**
651
- * Sets or clears the map's maximum pitch.
652
- * If the map's current pitch is higher than the new maximum,
653
- * the map will pitch to the new maximum.
654
- *
655
- * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.
656
- *
657
- * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
658
- * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).
659
- */
660
- setMaxPitch(maxPitch) {
661
- maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
662
- if (maxPitch > maxPitchThreshold) {
663
- throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);
664
- }
665
- if (maxPitch >= this.transform.minPitch) {
666
- this.transform.maxPitch = maxPitch;
667
- if (this.getPitch() > maxPitch) this.setPitch(maxPitch);
668
- return this;
669
- } else throw new Error('maxPitch must be greater than the current minPitch');
670
- }
671
-
672
- /**
673
- * Returns the map's maximum allowable pitch.
674
- *
675
- * @returns The maxPitch
676
- */
677
- getMaxPitch() {
678
- return this.transform.maxPitch;
679
- }
680
-
681
- /**
682
- * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:
683
- *
684
- * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire
685
- * container, there will be blank space beyond 180 and -180 degrees longitude.
686
- * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the
687
- * map and the other on the left edge of the map) at every zoom level.
688
- * @returns The renderWorldCopies
689
- * @example
690
- * ```ts
691
- * let worldCopiesRendered = map.getRenderWorldCopies();
692
- * ```
693
- * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)
694
- */
695
- getRenderWorldCopies() {
696
- return this.transform.renderWorldCopies;
697
- }
698
-
699
- /**
700
- * Sets the state of `renderWorldCopies`.
701
- *
702
- * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:
703
- *
704
- * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire
705
- * container, there will be blank space beyond 180 and -180 degrees longitude.
706
- * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the
707
- * map and the other on the left edge of the map) at every zoom level.
708
- *
709
- * `undefined` is treated as `true`, `null` is treated as `false`.
710
- * @example
711
- * ```ts
712
- * map.setRenderWorldCopies(true);
713
- * ```
714
- */
715
- setRenderWorldCopies(renderWorldCopies) {
716
- this.transform.renderWorldCopies = renderWorldCopies;
717
- }
718
-
719
- /**
720
- * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`,
721
- * that correspond to the specified geographical location.
722
- *
723
- * @param lnglat - The geographical location to project.
724
- * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`.
725
- * @example
726
- * ```ts
727
- * let coordinate = [-122.420679, 37.772537];
728
- * let point = map.project(coordinate);
729
- * ```
730
- */
731
- project(lnglat) {
732
- return this.transform.locationPoint(_lng_lat.LngLat.convert(lnglat));
733
- }
734
-
735
- /**
736
- * Returns a {@link LngLat} representing geographical coordinates that correspond
737
- * to the specified pixel coordinates.
738
- *
739
- * @param point - The pixel coordinates to unproject.
740
- * @returns The {@link LngLat} corresponding to `point`.
741
- * @example
742
- * ```ts
743
- * map.on('click', (e) => {
744
- * // When the map is clicked, get the geographic coordinate.
745
- * let coordinate = map.unproject(e.point);
746
- * });
747
- * ```
748
- */
749
- unproject(point) {
750
- return this.transform.pointLocation(_pointGeometry.default.convert(point));
751
- }
752
-
753
- /**
754
- * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.
755
- * @returns true if the map is moving.
756
- * @example
757
- * ```ts
758
- * let isMoving = map.isMoving();
759
- * ```
760
- */
761
- isMoving() {
762
- var _this$handlers;
763
- return this._moving || ((_this$handlers = this.handlers) === null || _this$handlers === void 0 ? void 0 : _this$handlers.isMoving());
764
- }
765
-
766
- /**
767
- * Returns true if the map is zooming due to a camera animation or user gesture.
768
- * @returns true if the map is zooming.
769
- * @example
770
- * ```ts
771
- * let isZooming = map.isZooming();
772
- * ```
773
- */
774
- isZooming() {
775
- var _this$handlers2;
776
- return this._zooming || ((_this$handlers2 = this.handlers) === null || _this$handlers2 === void 0 ? void 0 : _this$handlers2.isZooming());
777
- }
778
-
779
- /**
780
- * Returns true if the map is rotating due to a camera animation or user gesture.
781
- * @returns true if the map is rotating.
782
- * @example
783
- * ```ts
784
- * map.isRotating();
785
- * ```
786
- */
787
- isRotating() {
788
- var _this$handlers3;
789
- return this._rotating || ((_this$handlers3 = this.handlers) === null || _this$handlers3 === void 0 ? void 0 : _this$handlers3.isRotating());
790
- }
791
-
792
- /**
793
- * Overload of the `on` method that allows to listen to events without specifying a layer.
794
- * @event
795
- * @param type - The type of the event.
796
- * @param listener - The listener callback.
797
- */
798
-
799
- /**
800
- * Overload of the `on` method that allows to listen to events without specifying a layer.
801
- * @event
802
- * @param type - The type of the event.
803
- * @param listener - The listener callback.
804
- */
805
-
806
- on(type, listener) {
807
- return super.on(type, listener);
808
- }
809
-
810
- /**
811
- * Overload of the `once` method that allows to listen to events without specifying a layer.
812
- * @event
813
- * @param type - The type of the event.
814
- * @param listener - The listener callback.
815
- */
816
-
817
- /**
818
- * Overload of the `once` method that allows to listen to events without specifying a layer.
819
- * @event
820
- * @param type - The type of the event.
821
- * @param listener - The listener callback.
822
- */
823
-
824
- once(type, listener) {
825
- return super.once(type, listener);
826
- }
827
-
828
- /**
829
- * Overload of the `off` method that allows to listen to events without specifying a layer.
830
- * @event
831
- * @param type - The type of the event.
832
- * @param listener - The function previously installed as a listener.
833
- */
834
-
835
- /**
836
- * Overload of the `off` method that allows to listen to events without specifying a layer.
837
- * @event
838
- * @param type - The type of the event.
839
- * @param listener - The function previously installed as a listener.
840
- */
841
-
842
- off(type, listener) {
843
- return super.off(type, listener);
844
- }
845
-
846
- /**
847
- * Returns the map's containing HTML element.
848
- *
849
- * @returns The map's container.
850
- */
851
- getContainer() {
852
- return this._container;
853
- }
854
-
855
- /**
856
- * Returns the HTML element containing the map's `<canvas>` element.
857
- *
858
- * If you want to add non-GL overlays to the map, you should append them to this element.
859
- *
860
- * This is the element to which event bindings for map interactivity (such as panning and zooming) are
861
- * attached. It will receive bubbled events from child elements such as the `<canvas>`, but not from
862
- * map controls.
863
- *
864
- * @returns The container of the map's `<canvas>`.
865
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
866
- */
867
- getCanvasContainer() {
868
- return this._canvasContainer;
869
- }
870
- _containerDimensions() {
871
- let width = 0;
872
- let height = 0;
873
- if (this._container) {
874
- width = this._container.clientWidth || 400;
875
- height = this._container.clientHeight || 300;
876
- }
877
- return [width, height];
878
- }
879
- _setupContainer() {
880
- const container = this._container;
881
- container.classList.add('l7-map');
882
- const canvasContainer = this._canvasContainer = _dom.DOM.create('div', 'l7-canvas-container', container);
883
- if (this._interactive) {
884
- canvasContainer.classList.add('l7-interactive');
885
- }
886
- this._container.addEventListener('scroll', this._onMapScroll, false);
887
- }
888
- /**
889
- * @internal
890
- * Update this map's style and sources, and re-render the map.
891
- *
892
- * @param updateStyle - mark the map's style for reprocessing as
893
- * well as its sources
894
- */
895
- _update() {
896
- this.triggerRepaint();
897
- return this;
898
- }
899
-
900
- /**
901
- * @internal
902
- * Request that the given callback be executed during the next render
903
- * frame. Schedule a render frame if one is not already scheduled.
904
- *
905
- * @returns An id that can be used to cancel the callback
906
- */
907
- _requestRenderFrame(callback) {
908
- this._update();
909
- return this._renderTaskQueue.add(callback);
910
- }
911
- _cancelRenderFrame(id) {
912
- this._renderTaskQueue.remove(id);
913
- }
914
-
915
- /**
916
- * @internal
917
- * Call when a (re-)render of the map is required:
918
- *
919
- * - The style has changed (`setPaintProperty()`, etc.)
920
- * - Source data has changed (e.g. tiles have finished loading)
921
- * - The map has is moving (or just finished moving)
922
- * - A transition is in progress
923
- *
924
- * @param paintStartTimeStamp - The time when the animation frame began executing.
925
- */
926
- _render(paintStartTimeStamp) {
927
- this._renderTaskQueue.run(paintStartTimeStamp);
928
- // A task queue callback may have fired a user event which may have removed the map
929
- if (this._removed) return;
930
- this.fire(new _evented.Event('render'));
931
- if (!this.isMoving()) {
932
- this.fire(new _evented.Event('idle'));
933
- }
934
- return this;
935
- }
936
-
937
- /**
938
- * Clean up and release all internal resources associated with this map.
939
- *
940
- * This includes DOM elements, event bindings, web workers, and WebGL resources.
941
- *
942
- * Use this method when you are done using the map and wish to ensure that it no
943
- * longer consumes browser resources. Afterwards, you must not call any other
944
- * methods on the map.
945
- */
946
- remove() {
947
- var _this$_resizeObserver;
948
- if (this._frameRequest) {
949
- this._frameRequest.abort();
950
- this._frameRequest = null;
951
- }
952
- this._renderTaskQueue.clear();
953
- this.handlers.destroy();
954
- delete this.handlers;
955
- (_this$_resizeObserver = this._resizeObserver) === null || _this$_resizeObserver === void 0 || _this$_resizeObserver.disconnect();
956
- _dom.DOM.remove(this._canvasContainer);
957
- this._container.classList.remove('l7-map');
958
- this._removed = true;
959
- this.fire(new _evented.Event('remove'));
960
- }
961
-
962
- /**
963
- * Trigger the rendering of a single frame. Use this method with custom layers to
964
- * repaint the map when the layer changes. Calling this multiple times before the
965
- * next frame is rendered will still result in only a single frame being rendered.
966
- * @example
967
- * ```ts
968
- * map.triggerRepaint();
969
- * ```
970
- */
971
- triggerRepaint() {
972
- if (!this._frameRequest) {
973
- this._frameRequest = new AbortController();
974
- _browser.browser.frameAsync(this._frameRequest).then(paintStartTimeStamp => {
975
- this._frameRequest = null;
976
- this._render(paintStartTimeStamp);
977
- }).catch(() => {}); // ignore abort error
978
- }
979
- }
980
-
981
- /**
982
- * Returns the elevation for the point where the camera is looking.
983
- * This value corresponds to:
984
- * "meters above sea level" * "exaggeration"
985
- * @returns The elevation.
986
- */
987
- getCameraTargetElevation() {
988
- return this.transform.elevation;
989
- }
990
- }
991
- exports.Map = Map;