@antv/l7-map 2.25.6 → 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
@@ -1,159 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { wrap } from "../util/util";
3
-
4
- /*
5
- * Approximate radius of the earth in meters.
6
- * Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84
7
- * 6371008.8 is one published "average radius" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4
8
- */
9
- export const earthRadius = 6371008.8;
10
-
11
- /**
12
- * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
13
- * or an object with `lng` and `lat` or `lon` and `lat` properties.
14
- *
15
- * @group Geography and Geometry
16
- *
17
- * @example
18
- * ```ts
19
- * let v1 = new LngLat(-122.420679, 37.772537);
20
- * let v2 = [-122.420679, 37.772537];
21
- * let v3 = {lon: -122.420679, lat: 37.772537};
22
- * ```
23
- */
24
-
25
- /**
26
- * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
27
- * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
28
- *
29
- * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
30
- * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
31
- *
32
- * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option
33
- * can also accept an `Array` of two numbers and will perform an implicit conversion.
34
- * This flexible type is documented as {@link LngLatLike}.
35
- *
36
- * @group Geography and Geometry
37
- *
38
- * @example
39
- * ```ts
40
- * let ll = new LngLat(-123.9749, 40.7736);
41
- * ll.lng; // = -123.9749
42
- * ```
43
- * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
44
- * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)
45
- * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)
46
- */
47
- export class LngLat {
48
- /**
49
- * @param lng - Longitude, measured in degrees.
50
- * @param lat - Latitude, measured in degrees.
51
- */
52
- constructor(lng, lat) {
53
- _defineProperty(this, "lng", void 0);
54
- _defineProperty(this, "lat", void 0);
55
- if (isNaN(lng) || isNaN(lat)) {
56
- throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
57
- }
58
- this.lng = +lng;
59
- this.lat = +lat;
60
- if (this.lat > 90 || this.lat < -90) {
61
- throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
62
- }
63
- }
64
-
65
- /**
66
- * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
67
- *
68
- * @returns The wrapped `LngLat` object.
69
- * @example
70
- * ```ts
71
- * let ll = new LngLat(286.0251, 40.7736);
72
- * let wrapped = ll.wrap();
73
- * wrapped.lng; // = -73.9749
74
- * ```
75
- */
76
- wrap() {
77
- return new LngLat(wrap(this.lng, -180, 180), this.lat);
78
- }
79
-
80
- /**
81
- * Returns the coordinates represented as an array of two numbers.
82
- *
83
- * @returns The coordinates represented as an array of longitude and latitude.
84
- * @example
85
- * ```ts
86
- * let ll = new LngLat(-73.9749, 40.7736);
87
- * ll.toArray(); // = [-73.9749, 40.7736]
88
- * ```
89
- */
90
- toArray() {
91
- return [this.lng, this.lat];
92
- }
93
-
94
- /**
95
- * Returns the coordinates represent as a string.
96
- *
97
- * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
98
- * @example
99
- * ```ts
100
- * let ll = new LngLat(-73.9749, 40.7736);
101
- * ll.toString(); // = "LngLat(-73.9749, 40.7736)"
102
- * ```
103
- */
104
- toString() {
105
- return `LngLat(${this.lng}, ${this.lat})`;
106
- }
107
-
108
- /**
109
- * Returns the approximate distance between a pair of coordinates in meters
110
- * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
111
- *
112
- * @param lngLat - coordinates to compute the distance to
113
- * @returns Distance in meters between the two coordinates.
114
- * @example
115
- * ```ts
116
- * let new_york = new LngLat(-74.0060, 40.7128);
117
- * let los_angeles = new LngLat(-118.2437, 34.0522);
118
- * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
119
- * ```
120
- */
121
- distanceTo(lngLat) {
122
- const rad = Math.PI / 180;
123
- const lat1 = this.lat * rad;
124
- const lat2 = lngLat.lat * rad;
125
- const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
126
- const maxMeters = earthRadius * Math.acos(Math.min(a, 1));
127
- return maxMeters;
128
- }
129
-
130
- /**
131
- * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties
132
- * to a `LngLat` object.
133
- *
134
- * If a `LngLat` object is passed in, the function returns it unchanged.
135
- *
136
- * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
137
- * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
138
- * @example
139
- * ```ts
140
- * let arr = [-73.9749, 40.7736];
141
- * let ll = LngLat.convert(arr);
142
- * ll; // = LngLat {lng: -73.9749, lat: 40.7736}
143
- * ```
144
- */
145
- static convert(input) {
146
- if (input instanceof LngLat) {
147
- return input;
148
- }
149
- if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
150
- return new LngLat(Number(input[0]), Number(input[1]));
151
- }
152
- if (!Array.isArray(input) && typeof input === 'object' && input !== null) {
153
- return new LngLat(
154
- // flow can't refine this to have one of lng or lat, so we have to cast to any
155
- Number('lng' in input ? input.lng : input.lon), Number(input.lat));
156
- }
157
- throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]');
158
- }
159
- }
@@ -1,217 +0,0 @@
1
- import type { LngLatLike } from './lng_lat';
2
- import { LngLat } from './lng_lat';
3
- /**
4
- * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,
5
- * or an array of numbers in [west, south, east, north] order.
6
- *
7
- * @group Geography and Geometry
8
- *
9
- * @example
10
- * ```ts
11
- * let v1 = new LngLatBounds(
12
- * new LngLat(-73.9876, 40.7661),
13
- * new LngLat(-73.9397, 40.8002)
14
- * );
15
- * let v2 = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
16
- * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
17
- * ```
18
- */
19
- export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];
20
- /**
21
- * A `LngLatBounds` object represents a geographical bounding box,
22
- * defined by its southwest and northeast points in longitude and latitude.
23
- *
24
- * If no arguments are provided to the constructor, a `null` bounding box is created.
25
- *
26
- * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option
27
- * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.
28
- * This flexible type is documented as {@link LngLatBoundsLike}.
29
- *
30
- * @group Geography and Geometry
31
- *
32
- * @example
33
- * ```ts
34
- * let sw = new LngLat(-73.9876, 40.7661);
35
- * let ne = new LngLat(-73.9397, 40.8002);
36
- * let llb = new LngLatBounds(sw, ne);
37
- * ```
38
- */
39
- export declare class LngLatBounds {
40
- _ne: LngLat;
41
- _sw: LngLat;
42
- /**
43
- * @param sw - The southwest corner of the bounding box.
44
- * OR array of 4 numbers in the order of west, south, east, north
45
- * OR array of 2 LngLatLike: [sw,ne]
46
- * @param ne - The northeast corner of the bounding box.
47
- * @example
48
- * ```ts
49
- * let sw = new LngLat(-73.9876, 40.7661);
50
- * let ne = new LngLat(-73.9397, 40.8002);
51
- * let llb = new LngLatBounds(sw, ne);
52
- * ```
53
- * OR
54
- * ```ts
55
- * let llb = new LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);
56
- * ```
57
- * OR
58
- * ```ts
59
- * let llb = new LngLatBounds([sw, ne]);
60
- * ```
61
- */
62
- constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike);
63
- /**
64
- * Set the northeast corner of the bounding box
65
- *
66
- * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.
67
- */
68
- setNorthEast(ne: LngLatLike): this;
69
- /**
70
- * Set the southwest corner of the bounding box
71
- *
72
- * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.
73
- */
74
- setSouthWest(sw: LngLatLike): this;
75
- /**
76
- * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.
77
- *
78
- * @param obj - object to extend to
79
- */
80
- extend(obj: LngLatLike | LngLatBoundsLike): this;
81
- /**
82
- * Returns the geographical coordinate equidistant from the bounding box's corners.
83
- *
84
- * @returns The bounding box's center.
85
- * @example
86
- * ```ts
87
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
88
- * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
89
- * ```
90
- */
91
- getCenter(): LngLat;
92
- /**
93
- * Returns the southwest corner of the bounding box.
94
- *
95
- * @returns The southwest corner of the bounding box.
96
- */
97
- getSouthWest(): LngLat;
98
- /**
99
- * Returns the northeast corner of the bounding box.
100
- *
101
- * @returns The northeast corner of the bounding box.
102
- */
103
- getNorthEast(): LngLat;
104
- /**
105
- * Returns the northwest corner of the bounding box.
106
- *
107
- * @returns The northwest corner of the bounding box.
108
- */
109
- getNorthWest(): LngLat;
110
- /**
111
- * Returns the southeast corner of the bounding box.
112
- *
113
- * @returns The southeast corner of the bounding box.
114
- */
115
- getSouthEast(): LngLat;
116
- /**
117
- * Returns the west edge of the bounding box.
118
- *
119
- * @returns The west edge of the bounding box.
120
- */
121
- getWest(): number;
122
- /**
123
- * Returns the south edge of the bounding box.
124
- *
125
- * @returns The south edge of the bounding box.
126
- */
127
- getSouth(): number;
128
- /**
129
- * Returns the east edge of the bounding box.
130
- *
131
- * @returns The east edge of the bounding box.
132
- */
133
- getEast(): number;
134
- /**
135
- * Returns the north edge of the bounding box.
136
- *
137
- * @returns The north edge of the bounding box.
138
- */
139
- getNorth(): number;
140
- /**
141
- * Returns the bounding box represented as an array.
142
- *
143
- * @returns The bounding box represented as an array, consisting of the
144
- * southwest and northeast coordinates of the bounding represented as arrays of numbers.
145
- * @example
146
- * ```ts
147
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
148
- * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
149
- * ```
150
- */
151
- toArray(): [number, number][];
152
- /**
153
- * Return the bounding box represented as a string.
154
- *
155
- * @returns The bounding box represents as a string of the format
156
- * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
157
- * @example
158
- * ```ts
159
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
160
- * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
161
- * ```
162
- */
163
- toString(): string;
164
- /**
165
- * Check if the bounding box is an empty/`null`-type box.
166
- *
167
- * @returns True if bounds have been defined, otherwise false.
168
- */
169
- isEmpty(): boolean;
170
- /**
171
- * Check if the point is within the bounding box.
172
- *
173
- * @param lnglat - geographic point to check against.
174
- * @returns `true` if the point is within the bounding box.
175
- * @example
176
- * ```ts
177
- * let llb = new LngLatBounds(
178
- * new LngLat(-73.9876, 40.7661),
179
- * new LngLat(-73.9397, 40.8002)
180
- * );
181
- *
182
- * let ll = new LngLat(-73.9567, 40.7789);
183
- *
184
- * console.log(llb.contains(ll)); // = true
185
- * ```
186
- */
187
- contains(lnglat: LngLatLike): boolean;
188
- /**
189
- * Converts an array to a `LngLatBounds` object.
190
- *
191
- * If a `LngLatBounds` object is passed in, the function returns it unchanged.
192
- *
193
- * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.
194
- *
195
- * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.
196
- * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
197
- * @example
198
- * ```ts
199
- * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
200
- * let llb = LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
201
- * ```
202
- */
203
- static convert(input: LngLatBoundsLike): LngLatBounds;
204
- /**
205
- * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.
206
- *
207
- * @param center - center coordinates of the new bounds.
208
- * @param radius - Distance in meters from the coordinates to extend the bounds.
209
- * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.
210
- * @example
211
- * ```ts
212
- * let center = new LngLat(-73.9749, 40.7736);
213
- * LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
214
- * ```
215
- */
216
- static fromLngLat(center: LngLat, radius?: number): LngLatBounds;
217
- }
@@ -1,334 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { LngLat } from "./lng_lat";
3
-
4
- /**
5
- * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,
6
- * or an array of numbers in [west, south, east, north] order.
7
- *
8
- * @group Geography and Geometry
9
- *
10
- * @example
11
- * ```ts
12
- * let v1 = new LngLatBounds(
13
- * new LngLat(-73.9876, 40.7661),
14
- * new LngLat(-73.9397, 40.8002)
15
- * );
16
- * let v2 = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
17
- * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
18
- * ```
19
- */
20
-
21
- /**
22
- * A `LngLatBounds` object represents a geographical bounding box,
23
- * defined by its southwest and northeast points in longitude and latitude.
24
- *
25
- * If no arguments are provided to the constructor, a `null` bounding box is created.
26
- *
27
- * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option
28
- * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.
29
- * This flexible type is documented as {@link LngLatBoundsLike}.
30
- *
31
- * @group Geography and Geometry
32
- *
33
- * @example
34
- * ```ts
35
- * let sw = new LngLat(-73.9876, 40.7661);
36
- * let ne = new LngLat(-73.9397, 40.8002);
37
- * let llb = new LngLatBounds(sw, ne);
38
- * ```
39
- */
40
- export class LngLatBounds {
41
- /**
42
- * @param sw - The southwest corner of the bounding box.
43
- * OR array of 4 numbers in the order of west, south, east, north
44
- * OR array of 2 LngLatLike: [sw,ne]
45
- * @param ne - The northeast corner of the bounding box.
46
- * @example
47
- * ```ts
48
- * let sw = new LngLat(-73.9876, 40.7661);
49
- * let ne = new LngLat(-73.9397, 40.8002);
50
- * let llb = new LngLatBounds(sw, ne);
51
- * ```
52
- * OR
53
- * ```ts
54
- * let llb = new LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);
55
- * ```
56
- * OR
57
- * ```ts
58
- * let llb = new LngLatBounds([sw, ne]);
59
- * ```
60
- */
61
- constructor(sw, ne) {
62
- _defineProperty(this, "_ne", void 0);
63
- _defineProperty(this, "_sw", void 0);
64
- if (!sw) {
65
- // noop
66
- } else if (ne) {
67
- this.setSouthWest(sw).setNorthEast(ne);
68
- } else if (Array.isArray(sw)) {
69
- if (sw.length === 4) {
70
- // 4 element array: west, south, east, north
71
- this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
72
- } else {
73
- this.setSouthWest(sw[0]).setNorthEast(sw[1]);
74
- }
75
- }
76
- }
77
-
78
- /**
79
- * Set the northeast corner of the bounding box
80
- *
81
- * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.
82
- */
83
- setNorthEast(ne) {
84
- this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);
85
- return this;
86
- }
87
-
88
- /**
89
- * Set the southwest corner of the bounding box
90
- *
91
- * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.
92
- */
93
- setSouthWest(sw) {
94
- this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);
95
- return this;
96
- }
97
-
98
- /**
99
- * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.
100
- *
101
- * @param obj - object to extend to
102
- */
103
- extend(obj) {
104
- const sw = this._sw,
105
- ne = this._ne;
106
- let sw2, ne2;
107
- if (obj instanceof LngLat) {
108
- sw2 = obj;
109
- ne2 = obj;
110
- } else if (obj instanceof LngLatBounds) {
111
- sw2 = obj._sw;
112
- ne2 = obj._ne;
113
- if (!sw2 || !ne2) return this;
114
- } else {
115
- if (Array.isArray(obj)) {
116
- if (obj.length === 4 || obj.every(Array.isArray)) {
117
- const lngLatBoundsObj = obj;
118
- return this.extend(LngLatBounds.convert(lngLatBoundsObj));
119
- } else {
120
- const lngLatObj = obj;
121
- return this.extend(LngLat.convert(lngLatObj));
122
- }
123
- } else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) {
124
- return this.extend(LngLat.convert(obj));
125
- }
126
- return this;
127
- }
128
- if (!sw && !ne) {
129
- this._sw = new LngLat(sw2.lng, sw2.lat);
130
- this._ne = new LngLat(ne2.lng, ne2.lat);
131
- } else {
132
- sw.lng = Math.min(sw2.lng, sw.lng);
133
- sw.lat = Math.min(sw2.lat, sw.lat);
134
- ne.lng = Math.max(ne2.lng, ne.lng);
135
- ne.lat = Math.max(ne2.lat, ne.lat);
136
- }
137
- return this;
138
- }
139
-
140
- /**
141
- * Returns the geographical coordinate equidistant from the bounding box's corners.
142
- *
143
- * @returns The bounding box's center.
144
- * @example
145
- * ```ts
146
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
147
- * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
148
- * ```
149
- */
150
- getCenter() {
151
- return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
152
- }
153
-
154
- /**
155
- * Returns the southwest corner of the bounding box.
156
- *
157
- * @returns The southwest corner of the bounding box.
158
- */
159
- getSouthWest() {
160
- return this._sw;
161
- }
162
-
163
- /**
164
- * Returns the northeast corner of the bounding box.
165
- *
166
- * @returns The northeast corner of the bounding box.
167
- */
168
- getNorthEast() {
169
- return this._ne;
170
- }
171
-
172
- /**
173
- * Returns the northwest corner of the bounding box.
174
- *
175
- * @returns The northwest corner of the bounding box.
176
- */
177
- getNorthWest() {
178
- return new LngLat(this.getWest(), this.getNorth());
179
- }
180
-
181
- /**
182
- * Returns the southeast corner of the bounding box.
183
- *
184
- * @returns The southeast corner of the bounding box.
185
- */
186
- getSouthEast() {
187
- return new LngLat(this.getEast(), this.getSouth());
188
- }
189
-
190
- /**
191
- * Returns the west edge of the bounding box.
192
- *
193
- * @returns The west edge of the bounding box.
194
- */
195
- getWest() {
196
- return this._sw.lng;
197
- }
198
-
199
- /**
200
- * Returns the south edge of the bounding box.
201
- *
202
- * @returns The south edge of the bounding box.
203
- */
204
- getSouth() {
205
- return this._sw.lat;
206
- }
207
-
208
- /**
209
- * Returns the east edge of the bounding box.
210
- *
211
- * @returns The east edge of the bounding box.
212
- */
213
- getEast() {
214
- return this._ne.lng;
215
- }
216
-
217
- /**
218
- * Returns the north edge of the bounding box.
219
- *
220
- * @returns The north edge of the bounding box.
221
- */
222
- getNorth() {
223
- return this._ne.lat;
224
- }
225
-
226
- /**
227
- * Returns the bounding box represented as an array.
228
- *
229
- * @returns The bounding box represented as an array, consisting of the
230
- * southwest and northeast coordinates of the bounding represented as arrays of numbers.
231
- * @example
232
- * ```ts
233
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
234
- * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
235
- * ```
236
- */
237
- toArray() {
238
- return [this._sw.toArray(), this._ne.toArray()];
239
- }
240
-
241
- /**
242
- * Return the bounding box represented as a string.
243
- *
244
- * @returns The bounding box represents as a string of the format
245
- * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
246
- * @example
247
- * ```ts
248
- * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
249
- * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
250
- * ```
251
- */
252
- toString() {
253
- return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
254
- }
255
-
256
- /**
257
- * Check if the bounding box is an empty/`null`-type box.
258
- *
259
- * @returns True if bounds have been defined, otherwise false.
260
- */
261
- isEmpty() {
262
- return !(this._sw && this._ne);
263
- }
264
-
265
- /**
266
- * Check if the point is within the bounding box.
267
- *
268
- * @param lnglat - geographic point to check against.
269
- * @returns `true` if the point is within the bounding box.
270
- * @example
271
- * ```ts
272
- * let llb = new LngLatBounds(
273
- * new LngLat(-73.9876, 40.7661),
274
- * new LngLat(-73.9397, 40.8002)
275
- * );
276
- *
277
- * let ll = new LngLat(-73.9567, 40.7789);
278
- *
279
- * console.log(llb.contains(ll)); // = true
280
- * ```
281
- */
282
- contains(lnglat) {
283
- const {
284
- lng,
285
- lat
286
- } = LngLat.convert(lnglat);
287
- const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat;
288
- let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng;
289
- if (this._sw.lng > this._ne.lng) {
290
- // wrapped coordinates
291
- containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng;
292
- }
293
- return containsLatitude && containsLongitude;
294
- }
295
-
296
- /**
297
- * Converts an array to a `LngLatBounds` object.
298
- *
299
- * If a `LngLatBounds` object is passed in, the function returns it unchanged.
300
- *
301
- * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.
302
- *
303
- * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.
304
- * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
305
- * @example
306
- * ```ts
307
- * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
308
- * let llb = LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
309
- * ```
310
- */
311
- static convert(input) {
312
- if (input instanceof LngLatBounds) return input;
313
- return new LngLatBounds(input);
314
- }
315
-
316
- /**
317
- * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.
318
- *
319
- * @param center - center coordinates of the new bounds.
320
- * @param radius - Distance in meters from the coordinates to extend the bounds.
321
- * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.
322
- * @example
323
- * ```ts
324
- * let center = new LngLat(-73.9749, 40.7736);
325
- * LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
326
- * ```
327
- */
328
- static fromLngLat(center, radius = 0) {
329
- const earthCircumferenceInMetersAtEquator = 40075017;
330
- const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator,
331
- lngAccuracy = latAccuracy / Math.cos(Math.PI / 180 * center.lat);
332
- return new LngLatBounds(new LngLat(center.lng - lngAccuracy, center.lat - latAccuracy), new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy));
333
- }
334
- }