@antv/l7-map 2.25.7 → 2.25.10

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/es/index.d.ts +5 -0
  2. package/es/index.js +4 -0
  3. package/es/map/camera.d.ts +690 -0
  4. package/es/map/camera.js +1138 -0
  5. package/es/map/css/l7.css +171 -0
  6. package/es/map/events.d.ts +384 -0
  7. package/es/map/events.js +231 -0
  8. package/es/map/geo/edge_insets.d.ts +97 -0
  9. package/es/map/geo/edge_insets.js +115 -0
  10. package/es/map/geo/lng_lat.d.ts +116 -0
  11. package/es/map/geo/lng_lat.js +159 -0
  12. package/es/map/geo/lng_lat_bounds.d.ts +217 -0
  13. package/es/map/geo/lng_lat_bounds.js +334 -0
  14. package/es/map/geo/mercator_coordinate.d.ts +113 -0
  15. package/es/map/geo/mercator_coordinate.js +142 -0
  16. package/es/map/geo/transform.d.ts +262 -0
  17. package/es/map/geo/transform.js +736 -0
  18. package/es/map/handler/box_zoom.d.ts +65 -0
  19. package/es/map/handler/box_zoom.js +145 -0
  20. package/es/map/handler/click_zoom.d.ts +24 -0
  21. package/es/map/handler/click_zoom.js +47 -0
  22. package/es/map/handler/cooperative_gestures.d.ts +40 -0
  23. package/es/map/handler/cooperative_gestures.js +94 -0
  24. package/es/map/handler/drag_handler.d.ts +88 -0
  25. package/es/map/handler/drag_handler.js +89 -0
  26. package/es/map/handler/drag_move_state_manager.d.ts +30 -0
  27. package/es/map/handler/drag_move_state_manager.js +94 -0
  28. package/es/map/handler/handler_util.d.ts +3 -0
  29. package/es/map/handler/handler_util.js +8 -0
  30. package/es/map/handler/keyboard.d.ts +88 -0
  31. package/es/map/handler/keyboard.js +197 -0
  32. package/es/map/handler/map_event.d.ts +46 -0
  33. package/es/map/handler/map_event.js +131 -0
  34. package/es/map/handler/mouse.d.ts +30 -0
  35. package/es/map/handler/mouse.js +85 -0
  36. package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
  37. package/es/map/handler/one_finger_touch_drag.js +39 -0
  38. package/es/map/handler/scroll_zoom.d.ts +102 -0
  39. package/es/map/handler/scroll_zoom.js +312 -0
  40. package/es/map/handler/shim/dblclick_zoom.d.ts +44 -0
  41. package/es/map/handler/shim/dblclick_zoom.js +60 -0
  42. package/es/map/handler/shim/drag_pan.d.ts +79 -0
  43. package/es/map/handler/shim/drag_pan.js +77 -0
  44. package/es/map/handler/shim/drag_rotate.d.ts +54 -0
  45. package/es/map/handler/shim/drag_rotate.js +66 -0
  46. package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
  47. package/es/map/handler/shim/two_fingers_touch.js +106 -0
  48. package/es/map/handler/tap_drag_zoom.d.ts +28 -0
  49. package/es/map/handler/tap_drag_zoom.js +92 -0
  50. package/es/map/handler/tap_recognizer.d.ts +35 -0
  51. package/es/map/handler/tap_recognizer.js +107 -0
  52. package/es/map/handler/tap_zoom.d.ts +28 -0
  53. package/es/map/handler/tap_zoom.js +87 -0
  54. package/es/map/handler/touch_pan.d.ts +40 -0
  55. package/es/map/handler/touch_pan.js +85 -0
  56. package/es/map/handler/transform-provider.d.ts +23 -0
  57. package/es/map/handler/transform-provider.js +35 -0
  58. package/es/map/handler/two_fingers_touch.d.ts +107 -0
  59. package/es/map/handler/two_fingers_touch.js +289 -0
  60. package/es/map/handler_inertia.d.ts +20 -0
  61. package/es/map/handler_inertia.js +128 -0
  62. package/es/map/handler_manager.d.ts +154 -0
  63. package/es/map/handler_manager.js +466 -0
  64. package/es/map/map.d.ts +637 -0
  65. package/es/map/map.js +984 -0
  66. package/es/map/util/abort_error.d.ts +15 -0
  67. package/es/map/util/abort_error.js +21 -0
  68. package/es/map/util/browser.d.ts +10 -0
  69. package/es/map/util/browser.js +30 -0
  70. package/es/map/util/dom.d.ts +30 -0
  71. package/es/map/util/dom.js +105 -0
  72. package/es/map/util/evented.d.ts +75 -0
  73. package/es/map/util/evented.js +158 -0
  74. package/es/map/util/simpleMapCoord.d.ts +31 -0
  75. package/es/map/util/simpleMapCoord.js +54 -0
  76. package/es/map/util/task_queue.d.ts +18 -0
  77. package/es/map/util/task_queue.js +54 -0
  78. package/es/map/util/util.d.ts +104 -0
  79. package/es/map/util/util.js +155 -0
  80. package/lib/index.d.ts +5 -0
  81. package/lib/index.js +33 -0
  82. package/lib/map/camera.d.ts +690 -0
  83. package/lib/map/camera.js +1145 -0
  84. package/lib/map/css/l7.css +171 -0
  85. package/lib/map/events.d.ts +384 -0
  86. package/lib/map/events.js +240 -0
  87. package/lib/map/geo/edge_insets.d.ts +97 -0
  88. package/lib/map/geo/edge_insets.js +122 -0
  89. package/lib/map/geo/lng_lat.d.ts +116 -0
  90. package/lib/map/geo/lng_lat.js +166 -0
  91. package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
  92. package/lib/map/geo/lng_lat_bounds.js +341 -0
  93. package/lib/map/geo/mercator_coordinate.d.ts +113 -0
  94. package/lib/map/geo/mercator_coordinate.js +157 -0
  95. package/lib/map/geo/transform.d.ts +262 -0
  96. package/lib/map/geo/transform.js +744 -0
  97. package/lib/map/handler/box_zoom.d.ts +65 -0
  98. package/lib/map/handler/box_zoom.js +153 -0
  99. package/lib/map/handler/click_zoom.d.ts +24 -0
  100. package/lib/map/handler/click_zoom.js +54 -0
  101. package/lib/map/handler/cooperative_gestures.d.ts +40 -0
  102. package/lib/map/handler/cooperative_gestures.js +101 -0
  103. package/lib/map/handler/drag_handler.d.ts +88 -0
  104. package/lib/map/handler/drag_handler.js +97 -0
  105. package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
  106. package/lib/map/handler/drag_move_state_manager.js +103 -0
  107. package/lib/map/handler/handler_util.d.ts +3 -0
  108. package/lib/map/handler/handler_util.js +14 -0
  109. package/lib/map/handler/keyboard.d.ts +88 -0
  110. package/lib/map/handler/keyboard.js +205 -0
  111. package/lib/map/handler/map_event.d.ts +46 -0
  112. package/lib/map/handler/map_event.js +140 -0
  113. package/lib/map/handler/mouse.d.ts +30 -0
  114. package/lib/map/handler/mouse.js +93 -0
  115. package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
  116. package/lib/map/handler/one_finger_touch_drag.js +47 -0
  117. package/lib/map/handler/scroll_zoom.d.ts +102 -0
  118. package/lib/map/handler/scroll_zoom.js +320 -0
  119. package/lib/map/handler/shim/dblclick_zoom.d.ts +44 -0
  120. package/lib/map/handler/shim/dblclick_zoom.js +68 -0
  121. package/lib/map/handler/shim/drag_pan.d.ts +79 -0
  122. package/lib/map/handler/shim/drag_pan.js +85 -0
  123. package/lib/map/handler/shim/drag_rotate.d.ts +54 -0
  124. package/lib/map/handler/shim/drag_rotate.js +74 -0
  125. package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
  126. package/lib/map/handler/shim/two_fingers_touch.js +114 -0
  127. package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
  128. package/lib/map/handler/tap_drag_zoom.js +99 -0
  129. package/lib/map/handler/tap_recognizer.d.ts +35 -0
  130. package/lib/map/handler/tap_recognizer.js +116 -0
  131. package/lib/map/handler/tap_zoom.d.ts +28 -0
  132. package/lib/map/handler/tap_zoom.js +94 -0
  133. package/lib/map/handler/touch_pan.d.ts +40 -0
  134. package/lib/map/handler/touch_pan.js +92 -0
  135. package/lib/map/handler/transform-provider.d.ts +23 -0
  136. package/lib/map/handler/transform-provider.js +43 -0
  137. package/lib/map/handler/two_fingers_touch.d.ts +107 -0
  138. package/lib/map/handler/two_fingers_touch.js +296 -0
  139. package/lib/map/handler_inertia.d.ts +20 -0
  140. package/lib/map/handler_inertia.js +136 -0
  141. package/lib/map/handler_manager.d.ts +154 -0
  142. package/lib/map/handler_manager.js +474 -0
  143. package/lib/map/map.d.ts +637 -0
  144. package/lib/map/map.js +991 -0
  145. package/lib/map/util/abort_error.d.ts +15 -0
  146. package/lib/map/util/abort_error.js +29 -0
  147. package/lib/map/util/browser.d.ts +10 -0
  148. package/lib/map/util/browser.js +36 -0
  149. package/lib/map/util/dom.d.ts +30 -0
  150. package/lib/map/util/dom.js +113 -0
  151. package/lib/map/util/evented.d.ts +75 -0
  152. package/lib/map/util/evented.js +167 -0
  153. package/lib/map/util/simpleMapCoord.d.ts +31 -0
  154. package/lib/map/util/simpleMapCoord.js +62 -0
  155. package/lib/map/util/task_queue.d.ts +18 -0
  156. package/lib/map/util/task_queue.js +62 -0
  157. package/lib/map/util/util.d.ts +104 -0
  158. package/lib/map/util/util.js +171 -0
  159. package/package.json +2 -2
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MapWheelEvent = exports.MapTouchEvent = exports.MapMouseEvent = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _evented = require("./util/evented");
10
+ var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
11
+ var _dom = require("./util/dom");
12
+ var _simpleMapCoord = require("./util/simpleMapCoord");
13
+ /**
14
+ * `MapEventType` - a mapping between the event name and the event value.
15
+ * These events are used with the {@link Map#on} method.
16
+ * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}.
17
+ * The following example can be used for all the events.
18
+ *
19
+ * @group Event Related
20
+ * @example
21
+ * ```ts
22
+ * // Initialize the map
23
+ * let map = new Map({ // map options });
24
+ * // Set an event listener
25
+ * map.on('the-event-name', () => {
26
+ * console.log('An event has occurred!');
27
+ * });
28
+ * ```
29
+ */
30
+
31
+ /**
32
+ * The base event for MapLibre
33
+ *
34
+ * @group Event Related
35
+ */
36
+
37
+ /**
38
+ * `MapMouseEvent` is the event type for mouse-related map events.
39
+ *
40
+ * @group Event Related
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // The `click` event is an example of a `MapMouseEvent`.
45
+ * // Set up an event listener on the map.
46
+ * map.on('click', (e) => {
47
+ * // The event object (e) contains information like the
48
+ * // coordinates of the point on the map that was clicked.
49
+ * console.log('A click event has occurred at ' + e.lngLat);
50
+ * });
51
+ * ```
52
+ */
53
+ class MapMouseEvent extends _evented.Event {
54
+ /**
55
+ * Prevents subsequent default processing of the event by the map.
56
+ *
57
+ * Calling this method will prevent the following default map behaviors:
58
+ *
59
+ * * On `mousedown` events, the behavior of {@link DragPanHandler}
60
+ * * On `mousedown` events, the behavior of {@link DragRotateHandler}
61
+ * * On `mousedown` events, the behavior of {@link BoxZoomHandler}
62
+ * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
63
+ *
64
+ */
65
+ preventDefault() {
66
+ this._defaultPrevented = true;
67
+ }
68
+
69
+ /**
70
+ * `true` if `preventDefault` has been called.
71
+ */
72
+ get defaultPrevented() {
73
+ return this._defaultPrevented;
74
+ }
75
+ constructor(type, map, originalEvent, data = {}) {
76
+ super(type, data);
77
+ /**
78
+ * The event type
79
+ */
80
+ /**
81
+ * The `Map` object that fired the event.
82
+ */
83
+ (0, _defineProperty2.default)(this, "target", void 0);
84
+ /**
85
+ * The DOM event which caused the map event.
86
+ */
87
+ (0, _defineProperty2.default)(this, "originalEvent", void 0);
88
+ /**
89
+ * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
90
+ */
91
+ (0, _defineProperty2.default)(this, "point", void 0);
92
+ /**
93
+ * The geographic location on the map of the mouse cursor.
94
+ */
95
+ (0, _defineProperty2.default)(this, "lngLat", void 0);
96
+ (0, _defineProperty2.default)(this, "_defaultPrevented", void 0);
97
+ const point = _dom.DOM.mousePos(map.getCanvasContainer(), originalEvent);
98
+ const lngLat = map.unproject(point);
99
+ this.point = point;
100
+ this.lngLat = lngLat;
101
+ this.originalEvent = originalEvent;
102
+ this._defaultPrevented = false;
103
+ this.target = map;
104
+ if (map.version === 'SIMPLE') {
105
+ const simpleMapCoord = new _simpleMapCoord.SimpleMapCoord(map.mapSize);
106
+ const [lng, lat] = simpleMapCoord.project([lngLat.lng, lngLat.lat]);
107
+ this.lngLat = {
108
+ lng,
109
+ lat
110
+ };
111
+ }
112
+ }
113
+ }
114
+
115
+ /**
116
+ * `MapTouchEvent` is the event type for touch-related map events.
117
+ *
118
+ * @group Event Related
119
+ */
120
+ exports.MapMouseEvent = MapMouseEvent;
121
+ class MapTouchEvent extends _evented.Event {
122
+ /**
123
+ * Prevents subsequent default processing of the event by the map.
124
+ *
125
+ * Calling this method will prevent the following default map behaviors:
126
+ *
127
+ * * On `touchstart` events, the behavior of {@link DragPanHandler}
128
+ * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler}
129
+ *
130
+ */
131
+ preventDefault() {
132
+ this._defaultPrevented = true;
133
+ }
134
+
135
+ /**
136
+ * `true` if `preventDefault` has been called.
137
+ */
138
+ get defaultPrevented() {
139
+ return this._defaultPrevented;
140
+ }
141
+ constructor(type, map, originalEvent) {
142
+ super(type);
143
+ /**
144
+ * The event type.
145
+ */
146
+ /**
147
+ * The `Map` object that fired the event.
148
+ */
149
+ (0, _defineProperty2.default)(this, "target", void 0);
150
+ /**
151
+ * The DOM event which caused the map event.
152
+ */
153
+ (0, _defineProperty2.default)(this, "originalEvent", void 0);
154
+ /**
155
+ * The geographic location on the map of the center of the touch event points.
156
+ */
157
+ (0, _defineProperty2.default)(this, "lngLat", void 0);
158
+ /**
159
+ * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
160
+ * corner.
161
+ */
162
+ (0, _defineProperty2.default)(this, "point", void 0);
163
+ /**
164
+ * The array of pixel coordinates corresponding to a
165
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
166
+ */
167
+ (0, _defineProperty2.default)(this, "points", void 0);
168
+ /**
169
+ * The geographical locations on the map corresponding to a
170
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
171
+ */
172
+ (0, _defineProperty2.default)(this, "lngLats", void 0);
173
+ (0, _defineProperty2.default)(this, "_defaultPrevented", void 0);
174
+ const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
175
+ const points = _dom.DOM.touchPos(map.getCanvasContainer(), touches);
176
+ const lngLats = points.map(t => map.unproject(t));
177
+ const point = points.reduce((prev, curr, i, arr) => {
178
+ return prev.add(curr.div(arr.length));
179
+ }, new _pointGeometry.default(0, 0));
180
+ const lngLat = map.unproject(point);
181
+ this.target = map;
182
+ this.points = points;
183
+ this.point = point;
184
+ this.lngLats = lngLats;
185
+ this.lngLat = lngLat;
186
+ this.originalEvent = originalEvent;
187
+ this._defaultPrevented = false;
188
+ }
189
+ }
190
+
191
+ /**
192
+ * `MapWheelEvent` is the event type for the `wheel` map event.
193
+ *
194
+ * @group Event Related
195
+ *
196
+ */
197
+ exports.MapTouchEvent = MapTouchEvent;
198
+ class MapWheelEvent extends _evented.Event {
199
+ /**
200
+ * Prevents subsequent default processing of the event by the map.
201
+ *
202
+ * Calling this method will prevent the behavior of {@link ScrollZoomHandler}.
203
+ */
204
+ preventDefault() {
205
+ this._defaultPrevented = true;
206
+ }
207
+
208
+ /**
209
+ * `true` if `preventDefault` has been called.
210
+ */
211
+ get defaultPrevented() {
212
+ return this._defaultPrevented;
213
+ }
214
+ /** */
215
+ constructor(type, map, originalEvent) {
216
+ super(type);
217
+ /**
218
+ * The event type
219
+ */
220
+ /**
221
+ * The `Map` object that fired the event.
222
+ */
223
+ (0, _defineProperty2.default)(this, "target", void 0);
224
+ /**
225
+ * The DOM event which caused the map event.
226
+ */
227
+ (0, _defineProperty2.default)(this, "originalEvent", void 0);
228
+ (0, _defineProperty2.default)(this, "_defaultPrevented", void 0);
229
+ this.target = map;
230
+ this._defaultPrevented = false;
231
+ this.originalEvent = originalEvent;
232
+ }
233
+ }
234
+
235
+ /**
236
+ * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.
237
+ *
238
+ * @group Event Related
239
+ */
240
+ exports.MapWheelEvent = MapWheelEvent;
@@ -0,0 +1,97 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import Point from '@mapbox/point-geometry';
3
+ /**
4
+ * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
5
+ * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
6
+ * on top of the map and having the vanishing point shift as UI elements resize.
7
+ *
8
+ * @group Geography and Geometry
9
+ */
10
+ export declare class EdgeInsets {
11
+ /**
12
+ * @defaultValue 0
13
+ */
14
+ top: number;
15
+ /**
16
+ * @defaultValue 0
17
+ */
18
+ bottom: number;
19
+ /**
20
+ * @defaultValue 0
21
+ */
22
+ left: number;
23
+ /**
24
+ * @defaultValue 0
25
+ */
26
+ right: number;
27
+ constructor(top?: number, bottom?: number, left?: number, right?: number);
28
+ /**
29
+ * Interpolates the inset in-place.
30
+ * This maintains the current inset value for any inset not present in `target`.
31
+ * @param start - interpolation start
32
+ * @param target - interpolation target
33
+ * @param t - interpolation step/weight
34
+ * @returns the insets
35
+ */
36
+ interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets;
37
+ /**
38
+ * Utility method that computes the new apprent center or vanishing point after applying insets.
39
+ * This is in pixels and with the top left being (0.0) and +y being downwards.
40
+ *
41
+ * @param width - the width
42
+ * @param height - the height
43
+ * @returns the point
44
+ */
45
+ getCenter(width: number, height: number): Point;
46
+ equals(other: PaddingOptions): boolean;
47
+ clone(): EdgeInsets;
48
+ /**
49
+ * Returns the current state as json, useful when you want to have a
50
+ * read-only representation of the inset.
51
+ *
52
+ * @returns state as json
53
+ */
54
+ toJSON(): PaddingOptions;
55
+ }
56
+ /**
57
+ * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be
58
+ * non-negative integers.
59
+ *
60
+ * @group Geography and Geometry
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * let bbox = [[-79, 43], [-73, 45]];
65
+ * map.fitBounds(bbox, {
66
+ * padding: {top: 10, bottom:25, left: 15, right: 5}
67
+ * });
68
+ * ```
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * let bbox = [[-79, 43], [-73, 45]];
73
+ * map.fitBounds(bbox, {
74
+ * padding: 20
75
+ * });
76
+ * ```
77
+ * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)
78
+ * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)
79
+ */
80
+ export type PaddingOptions = {
81
+ /**
82
+ * Padding in pixels from the top of the map canvas.
83
+ */
84
+ top: number;
85
+ /**
86
+ * Padding in pixels from the bottom of the map canvas.
87
+ */
88
+ bottom: number;
89
+ /**
90
+ * Padding in pixels from the left of the map canvas.
91
+ */
92
+ right: number;
93
+ /**
94
+ * Padding in pixels from the right of the map canvas.
95
+ */
96
+ left: number;
97
+ };
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.EdgeInsets = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
10
+ var _util = require("../util/util");
11
+ /**
12
+ * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
13
+ * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
14
+ * on top of the map and having the vanishing point shift as UI elements resize.
15
+ *
16
+ * @group Geography and Geometry
17
+ */
18
+ class EdgeInsets {
19
+ constructor(top = 0, bottom = 0, left = 0, right = 0) {
20
+ /**
21
+ * @defaultValue 0
22
+ */
23
+ (0, _defineProperty2.default)(this, "top", void 0);
24
+ /**
25
+ * @defaultValue 0
26
+ */
27
+ (0, _defineProperty2.default)(this, "bottom", void 0);
28
+ /**
29
+ * @defaultValue 0
30
+ */
31
+ (0, _defineProperty2.default)(this, "left", void 0);
32
+ /**
33
+ * @defaultValue 0
34
+ */
35
+ (0, _defineProperty2.default)(this, "right", void 0);
36
+ if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
37
+ throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
38
+ }
39
+ this.top = top;
40
+ this.bottom = bottom;
41
+ this.left = left;
42
+ this.right = right;
43
+ }
44
+
45
+ /**
46
+ * Interpolates the inset in-place.
47
+ * This maintains the current inset value for any inset not present in `target`.
48
+ * @param start - interpolation start
49
+ * @param target - interpolation target
50
+ * @param t - interpolation step/weight
51
+ * @returns the insets
52
+ */
53
+ interpolate(start, target, t) {
54
+ if (target.top != null && start.top != null) this.top = _util.interpolates.number(start.top, target.top, t);
55
+ if (target.bottom != null && start.bottom != null) this.bottom = _util.interpolates.number(start.bottom, target.bottom, t);
56
+ if (target.left != null && start.left != null) this.left = _util.interpolates.number(start.left, target.left, t);
57
+ if (target.right != null && start.right != null) this.right = _util.interpolates.number(start.right, target.right, t);
58
+ return this;
59
+ }
60
+
61
+ /**
62
+ * Utility method that computes the new apprent center or vanishing point after applying insets.
63
+ * This is in pixels and with the top left being (0.0) and +y being downwards.
64
+ *
65
+ * @param width - the width
66
+ * @param height - the height
67
+ * @returns the point
68
+ */
69
+ getCenter(width, height) {
70
+ // Clamp insets so they never overflow width/height and always calculate a valid center
71
+ const x = (0, _util.clamp)((this.left + width - this.right) / 2, 0, width);
72
+ const y = (0, _util.clamp)((this.top + height - this.bottom) / 2, 0, height);
73
+ return new _pointGeometry.default(x, y);
74
+ }
75
+ equals(other) {
76
+ return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
77
+ }
78
+ clone() {
79
+ return new EdgeInsets(this.top, this.bottom, this.left, this.right);
80
+ }
81
+
82
+ /**
83
+ * Returns the current state as json, useful when you want to have a
84
+ * read-only representation of the inset.
85
+ *
86
+ * @returns state as json
87
+ */
88
+ toJSON() {
89
+ return {
90
+ top: this.top,
91
+ bottom: this.bottom,
92
+ left: this.left,
93
+ right: this.right
94
+ };
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be
100
+ * non-negative integers.
101
+ *
102
+ * @group Geography and Geometry
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * let bbox = [[-79, 43], [-73, 45]];
107
+ * map.fitBounds(bbox, {
108
+ * padding: {top: 10, bottom:25, left: 15, right: 5}
109
+ * });
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * let bbox = [[-79, 43], [-73, 45]];
115
+ * map.fitBounds(bbox, {
116
+ * padding: 20
117
+ * });
118
+ * ```
119
+ * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)
120
+ * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)
121
+ */
122
+ exports.EdgeInsets = EdgeInsets;
@@ -0,0 +1,116 @@
1
+ export declare const earthRadius = 6371008.8;
2
+ /**
3
+ * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
4
+ * or an object with `lng` and `lat` or `lon` and `lat` properties.
5
+ *
6
+ * @group Geography and Geometry
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * let v1 = new LngLat(-122.420679, 37.772537);
11
+ * let v2 = [-122.420679, 37.772537];
12
+ * let v3 = {lon: -122.420679, lat: 37.772537};
13
+ * ```
14
+ */
15
+ export type LngLatLike = LngLat | {
16
+ lng: number;
17
+ lat: number;
18
+ } | {
19
+ lon: number;
20
+ lat: number;
21
+ } | [number, number];
22
+ /**
23
+ * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
24
+ * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
25
+ *
26
+ * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
27
+ * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
28
+ *
29
+ * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option
30
+ * can also accept an `Array` of two numbers and will perform an implicit conversion.
31
+ * This flexible type is documented as {@link LngLatLike}.
32
+ *
33
+ * @group Geography and Geometry
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * let ll = new LngLat(-123.9749, 40.7736);
38
+ * ll.lng; // = -123.9749
39
+ * ```
40
+ * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
41
+ * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)
42
+ * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)
43
+ */
44
+ export declare class LngLat {
45
+ lng: number;
46
+ lat: number;
47
+ /**
48
+ * @param lng - Longitude, measured in degrees.
49
+ * @param lat - Latitude, measured in degrees.
50
+ */
51
+ constructor(lng: number, lat: number);
52
+ /**
53
+ * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
54
+ *
55
+ * @returns The wrapped `LngLat` object.
56
+ * @example
57
+ * ```ts
58
+ * let ll = new LngLat(286.0251, 40.7736);
59
+ * let wrapped = ll.wrap();
60
+ * wrapped.lng; // = -73.9749
61
+ * ```
62
+ */
63
+ wrap(): LngLat;
64
+ /**
65
+ * Returns the coordinates represented as an array of two numbers.
66
+ *
67
+ * @returns The coordinates represented as an array of longitude and latitude.
68
+ * @example
69
+ * ```ts
70
+ * let ll = new LngLat(-73.9749, 40.7736);
71
+ * ll.toArray(); // = [-73.9749, 40.7736]
72
+ * ```
73
+ */
74
+ toArray(): [number, number];
75
+ /**
76
+ * Returns the coordinates represent as a string.
77
+ *
78
+ * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
79
+ * @example
80
+ * ```ts
81
+ * let ll = new LngLat(-73.9749, 40.7736);
82
+ * ll.toString(); // = "LngLat(-73.9749, 40.7736)"
83
+ * ```
84
+ */
85
+ toString(): string;
86
+ /**
87
+ * Returns the approximate distance between a pair of coordinates in meters
88
+ * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
89
+ *
90
+ * @param lngLat - coordinates to compute the distance to
91
+ * @returns Distance in meters between the two coordinates.
92
+ * @example
93
+ * ```ts
94
+ * let new_york = new LngLat(-74.0060, 40.7128);
95
+ * let los_angeles = new LngLat(-118.2437, 34.0522);
96
+ * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
97
+ * ```
98
+ */
99
+ distanceTo(lngLat: LngLat): number;
100
+ /**
101
+ * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties
102
+ * to a `LngLat` object.
103
+ *
104
+ * If a `LngLat` object is passed in, the function returns it unchanged.
105
+ *
106
+ * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
107
+ * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
108
+ * @example
109
+ * ```ts
110
+ * let arr = [-73.9749, 40.7736];
111
+ * let ll = LngLat.convert(arr);
112
+ * ll; // = LngLat {lng: -73.9749, lat: 40.7736}
113
+ * ```
114
+ */
115
+ static convert(input: LngLatLike): LngLat;
116
+ }