@antv/l7-map 2.9.32-alpha.2 → 2.9.33

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 (168) hide show
  1. package/es/camera.d.ts +84 -0
  2. package/es/camera.js +765 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +421 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +118 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +81 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +167 -0
  12. package/es/geo/mercator.d.ts +28 -0
  13. package/es/geo/mercator.js +91 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +231 -0
  16. package/es/geo/simple.d.ts +28 -0
  17. package/es/geo/simple.js +90 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +971 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +83 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +200 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +59 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +12 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +75 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +105 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +61 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +39 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +184 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +684 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +10 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +162 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +131 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +129 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +54 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +56 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +56 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +12 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +353 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +72 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +96 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +80 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +130 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +120 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +114 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +62 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +115 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +128 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +110 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +88 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +67 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +134 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +156 -0
  94. package/es/index.d.ts +3 -0
  95. package/es/index.js +3 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +463 -0
  100. package/es/util.d.ts +18 -0
  101. package/es/util.js +84 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +133 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +218 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +45 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +106 -0
  112. package/lib/camera.js +533 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +278 -0
  115. package/lib/geo/edge_insets.js +76 -0
  116. package/lib/geo/lng_lat.js +73 -0
  117. package/lib/geo/lng_lat_bounds.js +138 -0
  118. package/lib/geo/mercator.js +91 -0
  119. package/lib/geo/point.js +176 -0
  120. package/lib/geo/simple.js +87 -0
  121. package/lib/geo/transform.js +503 -0
  122. package/lib/handler/IHandler.js +17 -0
  123. package/lib/handler/blockable_map_event.js +71 -0
  124. package/lib/handler/box_zoom.js +139 -0
  125. package/lib/handler/click_zoom.js +59 -0
  126. package/lib/handler/events/event.js +38 -0
  127. package/lib/handler/events/index.js +38 -0
  128. package/lib/handler/events/map_mouse_event.js +44 -0
  129. package/lib/handler/events/map_touch_event.js +48 -0
  130. package/lib/handler/events/map_wheel_event.js +36 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +149 -0
  133. package/lib/handler/handler_manager.js +455 -0
  134. package/lib/handler/handler_util.js +35 -0
  135. package/lib/handler/keyboard.js +131 -0
  136. package/lib/handler/map_event.js +91 -0
  137. package/lib/handler/mouse/index.js +38 -0
  138. package/lib/handler/mouse/mouse_handler.js +103 -0
  139. package/lib/handler/mouse/mousepan_handler.js +48 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +47 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +47 -0
  142. package/lib/handler/mouse/util.js +44 -0
  143. package/lib/handler/scroll_zoom.js +225 -0
  144. package/lib/handler/shim/dblclick_zoom.js +46 -0
  145. package/lib/handler/shim/drag_pan.js +55 -0
  146. package/lib/handler/shim/drag_rotate.js +49 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +71 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +102 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +106 -0
  150. package/lib/handler/tap/tap_recognizer.js +66 -0
  151. package/lib/handler/tap/tap_zoom.js +99 -0
  152. package/lib/handler/touch/index.js +41 -0
  153. package/lib/handler/touch/touch_pan.js +110 -0
  154. package/lib/handler/touch/touch_pitch.js +86 -0
  155. package/lib/handler/touch/touch_rotate.js +65 -0
  156. package/lib/handler/touch/touch_zoom.js +56 -0
  157. package/lib/handler/touch/two_touch.js +105 -0
  158. package/lib/hash.js +120 -0
  159. package/lib/index.js +21 -0
  160. package/lib/interface.js +17 -0
  161. package/lib/map.js +308 -0
  162. package/lib/util.js +97 -0
  163. package/lib/utils/Aabb.js +90 -0
  164. package/lib/utils/dom.js +159 -0
  165. package/lib/utils/performance.js +80 -0
  166. package/lib/utils/primitives.js +63 -0
  167. package/lib/utils/task_queue.js +72 -0
  168. package/package.json +3 -3
package/lib/camera.js ADDED
@@ -0,0 +1,533 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/camera.ts
23
+ var camera_exports = {};
24
+ __export(camera_exports, {
25
+ default: () => Camera
26
+ });
27
+ module.exports = __toCommonJS(camera_exports);
28
+ var import_eventemitter3 = require("eventemitter3");
29
+ var import_lodash = require("lodash");
30
+ var import_lng_lat = __toESM(require("./geo/lng_lat"));
31
+ var import_lng_lat_bounds = __toESM(require("./geo/lng_lat_bounds"));
32
+ var import_point = __toESM(require("./geo/point"));
33
+ var import_transform = __toESM(require("./geo/transform"));
34
+ var import_event = require("./handler/events/event");
35
+ var import_util = require("./util");
36
+ var Camera = class extends import_eventemitter3.EventEmitter {
37
+ constructor(options) {
38
+ super();
39
+ this.renderFrameCallback = () => {
40
+ const t = Math.min(((0, import_util.now)() - this.easeStart) / this.easeOptions.duration, 1);
41
+ this.onEaseFrame(this.easeOptions.easing(t));
42
+ if (t < 1) {
43
+ this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
44
+ } else {
45
+ this.stop();
46
+ }
47
+ };
48
+ this.options = options;
49
+ const { minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies } = options;
50
+ this.moving = false;
51
+ this.zooming = false;
52
+ this.bearingSnap = options.bearingSnap;
53
+ this.pitchEnabled = options.pitchEnabled;
54
+ this.rotateEnabled = options.rotateEnabled;
55
+ this.transform = new import_transform.default(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
56
+ }
57
+ requestRenderFrame(cb) {
58
+ return 0;
59
+ }
60
+ cancelRenderFrame(_) {
61
+ return;
62
+ }
63
+ getCenter() {
64
+ const { lng, lat } = this.transform.center;
65
+ return new import_lng_lat.default(lng, lat);
66
+ }
67
+ getZoom() {
68
+ return this.transform.zoom;
69
+ }
70
+ getPitch() {
71
+ return this.transform.pitch;
72
+ }
73
+ setCenter(center, eventData) {
74
+ return this.jumpTo({ center }, eventData);
75
+ }
76
+ setPitch(pitch, eventData) {
77
+ this.jumpTo({ pitch }, eventData);
78
+ return this;
79
+ }
80
+ getBearing() {
81
+ return this.transform.bearing;
82
+ }
83
+ panTo(lnglat, options, eventData) {
84
+ return this.easeTo((0, import_lodash.merge)({
85
+ center: lnglat
86
+ }, options), eventData);
87
+ }
88
+ zoomOut(options, eventData) {
89
+ this.zoomTo(this.getZoom() - 1, options, eventData);
90
+ return this;
91
+ }
92
+ setBearing(bearing, eventData) {
93
+ this.jumpTo({ bearing }, eventData);
94
+ return this;
95
+ }
96
+ setZoom(zoom, eventData) {
97
+ this.jumpTo({ zoom }, eventData);
98
+ return this;
99
+ }
100
+ zoomIn(options, eventData) {
101
+ this.zoomTo(this.getZoom() + 1, options, eventData);
102
+ return this;
103
+ }
104
+ zoomTo(zoom, options, eventData) {
105
+ return this.easeTo((0, import_lodash.merge)({
106
+ zoom
107
+ }, options), eventData);
108
+ }
109
+ getPadding() {
110
+ return this.transform.padding;
111
+ }
112
+ setPadding(padding, eventData) {
113
+ this.jumpTo({ padding }, eventData);
114
+ return this;
115
+ }
116
+ rotateTo(bearing, options, eventData) {
117
+ return this.easeTo((0, import_lodash.merge)({
118
+ bearing
119
+ }, options), eventData);
120
+ }
121
+ resetNorth(options, eventData) {
122
+ this.rotateTo(0, (0, import_lodash.merge)({ duration: 1e3 }, options), eventData);
123
+ return this;
124
+ }
125
+ resetNorthPitch(options, eventData) {
126
+ this.easeTo((0, import_lodash.merge)({
127
+ bearing: 0,
128
+ pitch: 0,
129
+ duration: 1e3
130
+ }, options), eventData);
131
+ return this;
132
+ }
133
+ fitBounds(bounds, options, eventData) {
134
+ return this.fitInternal(this.cameraForBounds(bounds, options), options, eventData);
135
+ }
136
+ cameraForBounds(bounds, options) {
137
+ bounds = import_lng_lat_bounds.default.convert(bounds);
138
+ return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0, options);
139
+ }
140
+ snapToNorth(options, eventData) {
141
+ if (Math.abs(this.getBearing()) < this.bearingSnap) {
142
+ return this.resetNorth(options, eventData);
143
+ }
144
+ return this;
145
+ }
146
+ jumpTo(options = {}, eventData) {
147
+ this.stop();
148
+ const tr = this.transform;
149
+ let zoomChanged = false;
150
+ let bearingChanged = false;
151
+ let pitchChanged = false;
152
+ if (options.zoom && tr.zoom !== +options.zoom) {
153
+ zoomChanged = true;
154
+ tr.zoom = +options.zoom;
155
+ }
156
+ if (options.center !== void 0) {
157
+ tr.center = import_lng_lat.default.convert(options.center);
158
+ }
159
+ if (options.bearing && tr.bearing !== +options.bearing) {
160
+ bearingChanged = true;
161
+ tr.bearing = +options.bearing;
162
+ }
163
+ if (options.pitch && tr.pitch !== +options.pitch) {
164
+ pitchChanged = true;
165
+ tr.pitch = +options.pitch;
166
+ }
167
+ if (options.padding != null && !tr.isPaddingEqual(options.padding)) {
168
+ tr.padding = options.padding;
169
+ }
170
+ this.emit("movestart", new import_event.Event("movestart", eventData));
171
+ this.emit("move", new import_event.Event("move", eventData));
172
+ if (zoomChanged) {
173
+ this.emit("zoomstart", new import_event.Event("zoomstart", eventData));
174
+ this.emit("zoom", new import_event.Event("zoom", eventData));
175
+ this.emit("zoomend", new import_event.Event("zoomend", eventData));
176
+ }
177
+ if (bearingChanged) {
178
+ this.emit("rotatestart", new import_event.Event("rotatestart", eventData));
179
+ this.emit("rotate", new import_event.Event("rotate", eventData));
180
+ this.emit("rotateend", new import_event.Event("rotateend", eventData));
181
+ }
182
+ if (pitchChanged) {
183
+ this.emit("pitchstart", new import_event.Event("pitchstart", eventData));
184
+ this.emit("pitch", new import_event.Event("pitch", eventData));
185
+ this.emit("pitchend", new import_event.Event("pitchend", eventData));
186
+ }
187
+ return this.emit("moveend", new import_event.Event("moveend", eventData));
188
+ }
189
+ easeTo(options = {}, eventData) {
190
+ options = (0, import_lodash.merge)({
191
+ offset: [0, 0],
192
+ duration: 500,
193
+ easing: import_util.ease
194
+ }, options);
195
+ if (options.animate === false || !options.essential && (0, import_util.prefersReducedMotion)()) {
196
+ options.duration = 0;
197
+ }
198
+ const tr = this.transform;
199
+ const startZoom = this.getZoom();
200
+ const startBearing = this.getBearing();
201
+ const startPitch = this.getPitch();
202
+ const startPadding = this.getPadding();
203
+ const zoom = options.zoom ? +options.zoom : startZoom;
204
+ const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
205
+ const pitch = options.pitch ? +options.pitch : startPitch;
206
+ const padding = options.padding ? options.padding : tr.padding;
207
+ const offsetAsPoint = import_point.default.convert(options.offset);
208
+ let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
209
+ const locationAtOffset = tr.pointLocation(pointAtOffset);
210
+ const center = import_lng_lat.default.convert(options.center || locationAtOffset);
211
+ this.normalizeCenter(center);
212
+ const from = tr.project(locationAtOffset);
213
+ const delta = tr.project(center).sub(from);
214
+ const finalScale = tr.zoomScale(zoom - startZoom);
215
+ let around;
216
+ let aroundPoint;
217
+ if (options.around) {
218
+ around = import_lng_lat.default.convert(options.around);
219
+ aroundPoint = tr.locationPoint(around);
220
+ }
221
+ const currently = {
222
+ moving: this.moving,
223
+ zooming: this.zooming,
224
+ rotating: this.rotating,
225
+ pitching: this.pitching
226
+ };
227
+ this.zooming = this.zooming || zoom !== startZoom;
228
+ this.rotating = this.rotating || startBearing !== bearing;
229
+ this.pitching = this.pitching || pitch !== startPitch;
230
+ this.padding = !tr.isPaddingEqual(padding);
231
+ this.easeId = options.easeId;
232
+ this.prepareEase(eventData, options.noMoveStart, currently);
233
+ clearTimeout(this.easeEndTimeoutID);
234
+ this.ease((k) => {
235
+ if (this.zooming) {
236
+ tr.zoom = (0, import_util.interpolate)(startZoom, zoom, k);
237
+ }
238
+ if (this.rotating && this.rotateEnabled) {
239
+ tr.bearing = (0, import_util.interpolate)(startBearing, bearing, k);
240
+ }
241
+ if (this.pitching && this.pitchEnabled) {
242
+ tr.pitch = (0, import_util.interpolate)(startPitch, pitch, k);
243
+ }
244
+ if (this.padding) {
245
+ tr.interpolatePadding(startPadding, padding, k);
246
+ pointAtOffset = tr.centerPoint.add(offsetAsPoint);
247
+ }
248
+ if (around) {
249
+ tr.setLocationAtPoint(around, aroundPoint);
250
+ } else {
251
+ const scale = tr.zoomScale(tr.zoom - startZoom);
252
+ const base = zoom > startZoom ? Math.min(2, finalScale) : Math.max(0.5, finalScale);
253
+ const speedup = Math.pow(base, 1 - k);
254
+ const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
255
+ tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
256
+ }
257
+ this.fireMoveEvents(eventData);
258
+ }, (interruptingEaseId) => {
259
+ this.afterEase(eventData, interruptingEaseId);
260
+ }, options);
261
+ return this;
262
+ }
263
+ flyTo(options = {}, eventData) {
264
+ if (!options.essential && (0, import_util.prefersReducedMotion)()) {
265
+ const coercedOptions = (0, import_util.pick)(options, [
266
+ "center",
267
+ "zoom",
268
+ "bearing",
269
+ "pitch",
270
+ "around"
271
+ ]);
272
+ return this.jumpTo(coercedOptions, eventData);
273
+ }
274
+ this.stop();
275
+ options = (0, import_lodash.merge)({
276
+ offset: [0, 0],
277
+ speed: 1.2,
278
+ curve: 1.42,
279
+ easing: import_util.ease
280
+ }, options);
281
+ const tr = this.transform;
282
+ const startZoom = this.getZoom();
283
+ const startBearing = this.getBearing();
284
+ const startPitch = this.getPitch();
285
+ const startPadding = this.getPadding();
286
+ const zoom = options.zoom ? (0, import_util.clamp)(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;
287
+ const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
288
+ const pitch = options.pitch ? +options.pitch : startPitch;
289
+ const padding = "padding" in options ? options.padding : tr.padding;
290
+ const scale = tr.zoomScale(zoom - startZoom);
291
+ const offsetAsPoint = import_point.default.convert(options.offset);
292
+ let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
293
+ const locationAtOffset = tr.pointLocation(pointAtOffset);
294
+ const center = import_lng_lat.default.convert(options.center || locationAtOffset);
295
+ this.normalizeCenter(center);
296
+ const from = tr.project(locationAtOffset);
297
+ const delta = tr.project(center).sub(from);
298
+ let rho = options.curve;
299
+ const w0 = Math.max(tr.width, tr.height);
300
+ const w1 = w0 / scale;
301
+ const u1 = delta.mag();
302
+ if ("minZoom" in options) {
303
+ const minZoom = (0, import_util.clamp)(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);
304
+ const wMax = w0 / tr.zoomScale(minZoom - startZoom);
305
+ rho = Math.sqrt(wMax / u1 * 2);
306
+ }
307
+ const rho2 = rho * rho;
308
+ function r(i) {
309
+ const b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
310
+ return Math.log(Math.sqrt(b * b + 1) - b);
311
+ }
312
+ function sinh(n) {
313
+ return (Math.exp(n) - Math.exp(-n)) / 2;
314
+ }
315
+ function cosh(n) {
316
+ return (Math.exp(n) + Math.exp(-n)) / 2;
317
+ }
318
+ function tanh(n) {
319
+ return sinh(n) / cosh(n);
320
+ }
321
+ const r0 = r(0);
322
+ let w = (s) => {
323
+ return cosh(r0) / cosh(r0 + rho * s);
324
+ };
325
+ let u = (s) => {
326
+ return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
327
+ };
328
+ let S = (r(1) - r0) / rho;
329
+ if (Math.abs(u1) < 1e-6 || !isFinite(S)) {
330
+ if (Math.abs(w0 - w1) < 1e-6) {
331
+ return this.easeTo(options, eventData);
332
+ }
333
+ const k = w1 < w0 ? -1 : 1;
334
+ S = Math.abs(Math.log(w1 / w0)) / rho;
335
+ u = () => {
336
+ return 0;
337
+ };
338
+ w = (s) => {
339
+ return Math.exp(k * rho * s);
340
+ };
341
+ }
342
+ if ("duration" in options) {
343
+ options.duration = +options.duration;
344
+ } else {
345
+ const V = "screenSpeed" in options ? +options.screenSpeed / rho : +options.speed;
346
+ options.duration = 1e3 * S / V;
347
+ }
348
+ if (options.maxDuration && options.duration > options.maxDuration) {
349
+ options.duration = 0;
350
+ }
351
+ this.zooming = true;
352
+ this.rotating = startBearing !== bearing;
353
+ this.pitching = pitch !== startPitch;
354
+ this.padding = !tr.isPaddingEqual(padding);
355
+ this.prepareEase(eventData, false);
356
+ this.ease((k) => {
357
+ const s = k * S;
358
+ const easeScale = 1 / w(s);
359
+ tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(easeScale);
360
+ if (this.rotating) {
361
+ tr.bearing = (0, import_util.interpolate)(startBearing, bearing, k);
362
+ }
363
+ if (this.pitching) {
364
+ tr.pitch = (0, import_util.interpolate)(startPitch, pitch, k);
365
+ }
366
+ if (this.padding) {
367
+ tr.interpolatePadding(startPadding, padding, k);
368
+ pointAtOffset = tr.centerPoint.add(offsetAsPoint);
369
+ }
370
+ const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(easeScale));
371
+ tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
372
+ this.fireMoveEvents(eventData);
373
+ }, () => this.afterEase(eventData), options);
374
+ return this;
375
+ }
376
+ fitScreenCoordinates(p0, p1, bearing, options, eventData) {
377
+ return this.fitInternal(this.cameraForBoxAndBearing(this.transform.pointLocation(import_point.default.convert(p0)), this.transform.pointLocation(import_point.default.convert(p1)), bearing, options), options, eventData);
378
+ }
379
+ stop(allowGestures, easeId) {
380
+ if (this.easeFrameId) {
381
+ this.cancelRenderFrame(this.easeFrameId);
382
+ delete this.easeFrameId;
383
+ delete this.onEaseFrame;
384
+ }
385
+ if (this.onEaseEnd) {
386
+ const onEaseEnd = this.onEaseEnd;
387
+ delete this.onEaseEnd;
388
+ onEaseEnd.call(this, easeId);
389
+ }
390
+ return this;
391
+ }
392
+ normalizeBearing(bearing, currentBearing) {
393
+ bearing = (0, import_util.wrap)(bearing, -180, 180);
394
+ const diff = Math.abs(bearing - currentBearing);
395
+ if (Math.abs(bearing - 360 - currentBearing) < diff) {
396
+ bearing -= 360;
397
+ }
398
+ if (Math.abs(bearing + 360 - currentBearing) < diff) {
399
+ bearing += 360;
400
+ }
401
+ return bearing;
402
+ }
403
+ normalizeCenter(center) {
404
+ const tr = this.transform;
405
+ if (!tr.renderWorldCopies || tr.lngRange) {
406
+ return;
407
+ }
408
+ const delta = center.lng - tr.center.lng;
409
+ center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
410
+ }
411
+ fireMoveEvents(eventData) {
412
+ this.emit("move", new import_event.Event("move", eventData));
413
+ if (this.zooming) {
414
+ this.emit("zoom", new import_event.Event("zoom", eventData));
415
+ }
416
+ if (this.rotating) {
417
+ this.emit("rotate", new import_event.Event("rotate", eventData));
418
+ }
419
+ if (this.pitching) {
420
+ this.emit("rotate", new import_event.Event("pitch", eventData));
421
+ }
422
+ }
423
+ prepareEase(eventData, noMoveStart = false, currently = {}) {
424
+ this.moving = true;
425
+ if (!noMoveStart && !currently.moving) {
426
+ this.emit("movestart", new import_event.Event("movestart", eventData));
427
+ }
428
+ if (this.zooming && !currently.zooming) {
429
+ this.emit("zoomstart", new import_event.Event("zoomstart", eventData));
430
+ }
431
+ if (this.rotating && !currently.rotating) {
432
+ this.emit("rotatestart", new import_event.Event("rotatestart", eventData));
433
+ }
434
+ if (this.pitching && !currently.pitching) {
435
+ this.emit("pitchstart", new import_event.Event("pitchstart", eventData));
436
+ }
437
+ }
438
+ afterEase(eventData, easeId) {
439
+ if (this.easeId && easeId && this.easeId === easeId) {
440
+ return;
441
+ }
442
+ delete this.easeId;
443
+ const wasZooming = this.zooming;
444
+ const wasRotating = this.rotating;
445
+ const wasPitching = this.pitching;
446
+ this.moving = false;
447
+ this.zooming = false;
448
+ this.rotating = false;
449
+ this.pitching = false;
450
+ this.padding = false;
451
+ if (wasZooming) {
452
+ this.emit("zoomend", new import_event.Event("zoomend", eventData));
453
+ }
454
+ if (wasRotating) {
455
+ this.emit("rotateend", new import_event.Event("rotateend", eventData));
456
+ }
457
+ if (wasPitching) {
458
+ this.emit("pitchend", new import_event.Event("pitchend", eventData));
459
+ }
460
+ this.emit("moveend", new import_event.Event("moveend", eventData));
461
+ }
462
+ ease(frame, finish, options) {
463
+ if (options.animate === false || options.duration === 0) {
464
+ frame(1);
465
+ finish();
466
+ } else {
467
+ this.easeStart = (0, import_util.now)();
468
+ this.easeOptions = options;
469
+ this.onEaseFrame = frame;
470
+ this.onEaseEnd = finish;
471
+ this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
472
+ }
473
+ }
474
+ cameraForBoxAndBearing(p0, p1, bearing, options) {
475
+ const defaultPadding = {
476
+ top: 0,
477
+ bottom: 0,
478
+ right: 0,
479
+ left: 0
480
+ };
481
+ options = (0, import_lodash.merge)({
482
+ padding: defaultPadding,
483
+ offset: [0, 0],
484
+ maxZoom: this.transform.maxZoom
485
+ }, options);
486
+ if (typeof options.padding === "number") {
487
+ const p = options.padding;
488
+ options.padding = {
489
+ top: p,
490
+ bottom: p,
491
+ right: p,
492
+ left: p
493
+ };
494
+ }
495
+ options.padding = (0, import_lodash.merge)(defaultPadding, options.padding);
496
+ const tr = this.transform;
497
+ const edgePadding = tr.padding;
498
+ const p0world = tr.project(import_lng_lat.default.convert(p0));
499
+ const p1world = tr.project(import_lng_lat.default.convert(p1));
500
+ const p0rotated = p0world.rotate(-bearing * Math.PI / 180);
501
+ const p1rotated = p1world.rotate(-bearing * Math.PI / 180);
502
+ const upperRight = new import_point.default(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));
503
+ const lowerLeft = new import_point.default(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));
504
+ const size = upperRight.sub(lowerLeft);
505
+ const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x;
506
+ const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y;
507
+ if (scaleY < 0 || scaleX < 0) {
508
+ return;
509
+ }
510
+ const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
511
+ const offset = import_point.default.convert(options.offset);
512
+ const paddingOffsetX = (options.padding.left - options.padding.right) / 2;
513
+ const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;
514
+ const offsetAtInitialZoom = new import_point.default(offset.x + paddingOffsetX, offset.y + paddingOffsetY);
515
+ const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));
516
+ const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));
517
+ return {
518
+ center,
519
+ zoom,
520
+ bearing
521
+ };
522
+ }
523
+ fitInternal(calculatedOptions, options, eventData) {
524
+ if (!calculatedOptions) {
525
+ return this;
526
+ }
527
+ options = (0, import_lodash.merge)(calculatedOptions, options);
528
+ delete options.padding;
529
+ return options.linear ? this.easeTo(options, eventData) : this.flyTo(options, eventData);
530
+ }
531
+ };
532
+ // Annotate the CommonJS export names for ESM import in node:
533
+ 0 && (module.exports = {});
package/lib/css/l7.css ADDED
@@ -0,0 +1,98 @@
1
+ .l7-map {
2
+ font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
3
+ overflow: hidden;
4
+ position: relative;
5
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
6
+ }
7
+
8
+ .l7-canvas {
9
+ position: absolute;
10
+ left: 0;
11
+ top: 0;
12
+ }
13
+
14
+ .l7-map:-webkit-full-screen {
15
+ width: 100%;
16
+ height: 100%;
17
+ }
18
+
19
+ .l7-canary {
20
+ background-color: salmon;
21
+ }
22
+
23
+ .l7-canvas-container.l7-interactive,
24
+ .l7-ctrl-group button.l7-ctrl-compass {
25
+ cursor: -webkit-grab;
26
+ cursor: -moz-grab;
27
+ cursor: grab;
28
+ -moz-user-select: none;
29
+ -webkit-user-select: none;
30
+ -ms-user-select: none;
31
+ user-select: none;
32
+ }
33
+
34
+ .l7-canvas-container.l7-interactive.l7-track-pointer {
35
+ cursor: pointer;
36
+ }
37
+
38
+ .l7-canvas-container.l7-interactive:active,
39
+ .l7-ctrl-group button.l7-ctrl-compass:active {
40
+ cursor: -webkit-grabbing;
41
+ cursor: -moz-grabbing;
42
+ cursor: grabbing;
43
+ }
44
+
45
+ .l7-canvas-container.l7-touch-zoom-rotate,
46
+ .l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
47
+ touch-action: pan-x pan-y;
48
+ }
49
+
50
+ .l7-canvas-container.l7-touch-drag-pan,
51
+ .l7-canvas-container.l7-touch-drag-pan .l7-canvas {
52
+ touch-action: pinch-zoom;
53
+ }
54
+
55
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
56
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
57
+ touch-action: none;
58
+ }
59
+
60
+ .l7-ctrl-top-left,
61
+ .l7-ctrl-top-right,
62
+ .l7-ctrl-bottom-left,
63
+ .l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }
64
+ .l7-ctrl-top-left { top: 0; left: 0; }
65
+ .l7-ctrl-top-right { top: 0; right: 0; }
66
+ .l7-ctrl-bottom-left { bottom: 0; left: 0; }
67
+ .l7-ctrl-bottom-right { right: 0; bottom: 0; }
68
+
69
+ .l7-ctrl {
70
+ clear: both;
71
+ pointer-events: auto;
72
+
73
+ /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
74
+ transform: translate(0, 0);
75
+ }
76
+ .l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }
77
+ .l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }
78
+ .l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }
79
+ .l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }
80
+
81
+
82
+ .l7-crosshair,
83
+ .l7-crosshair .l7-interactive,
84
+ .l7-crosshair .l7-interactive:active {
85
+ cursor: crosshair;
86
+ }
87
+
88
+ .l7-boxzoom {
89
+ position: absolute;
90
+ top: 0;
91
+ left: 0;
92
+ width: 0;
93
+ height: 0;
94
+ background: #fff;
95
+ border: 2px dotted #202020;
96
+ opacity: 0.5;
97
+ z-index: 10;
98
+ }