@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.6
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.
- package/README.md +27 -6
- package/es/index.d.ts +3 -4
- package/es/index.js +2 -4
- package/es/map/camera.d.ts +690 -0
- package/es/map/camera.js +1138 -0
- package/{lib → es/map}/css/l7.css +41 -7
- package/es/map/events.d.ts +384 -0
- package/es/map/events.js +222 -0
- package/es/map/geo/edge_insets.d.ts +97 -0
- package/es/{geo → map/geo}/edge_insets.js +55 -33
- package/es/map/geo/lng_lat.d.ts +116 -0
- package/es/map/geo/lng_lat.js +159 -0
- package/es/map/geo/lng_lat_bounds.d.ts +217 -0
- package/es/map/geo/lng_lat_bounds.js +334 -0
- package/es/map/geo/mercator_coordinate.d.ts +113 -0
- package/es/map/geo/mercator_coordinate.js +142 -0
- package/es/map/geo/transform.d.ts +262 -0
- package/es/map/geo/transform.js +736 -0
- package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
- package/es/map/handler/box_zoom.js +145 -0
- package/es/map/handler/click_zoom.d.ts +24 -0
- package/es/map/handler/click_zoom.js +47 -0
- package/es/map/handler/cooperative_gestures.d.ts +40 -0
- package/es/map/handler/cooperative_gestures.js +94 -0
- package/es/map/handler/drag_handler.d.ts +88 -0
- package/es/map/handler/drag_handler.js +89 -0
- package/es/map/handler/drag_move_state_manager.d.ts +30 -0
- package/es/map/handler/drag_move_state_manager.js +94 -0
- package/es/map/handler/handler_util.d.ts +3 -0
- package/es/{handler → map/handler}/handler_util.js +1 -2
- package/es/map/handler/keyboard.d.ts +88 -0
- package/es/map/handler/keyboard.js +197 -0
- package/es/map/handler/map_event.d.ts +46 -0
- package/es/map/handler/map_event.js +131 -0
- package/es/map/handler/mouse.d.ts +30 -0
- package/es/map/handler/mouse.js +85 -0
- package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/es/map/handler/one_finger_touch_drag.js +39 -0
- package/es/map/handler/scroll_zoom.d.ts +102 -0
- package/es/map/handler/scroll_zoom.js +312 -0
- package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
- package/es/map/handler/shim/drag_pan.d.ts +79 -0
- package/es/map/handler/shim/drag_pan.js +77 -0
- package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/es/map/handler/shim/drag_rotate.js +66 -0
- package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/es/map/handler/shim/two_fingers_touch.js +106 -0
- package/es/map/handler/tap_drag_zoom.d.ts +28 -0
- package/es/map/handler/tap_drag_zoom.js +92 -0
- package/es/map/handler/tap_recognizer.d.ts +35 -0
- package/es/map/handler/tap_recognizer.js +107 -0
- package/es/map/handler/tap_zoom.d.ts +28 -0
- package/es/map/handler/tap_zoom.js +87 -0
- package/es/map/handler/touch_pan.d.ts +40 -0
- package/es/map/handler/touch_pan.js +85 -0
- package/es/map/handler/transform-provider.d.ts +23 -0
- package/es/map/handler/transform-provider.js +35 -0
- package/es/map/handler/two_fingers_touch.d.ts +107 -0
- package/es/map/handler/two_fingers_touch.js +289 -0
- package/es/map/handler_inertia.d.ts +20 -0
- package/es/{handler → map}/handler_inertia.js +36 -50
- package/es/map/handler_manager.d.ts +154 -0
- package/es/map/handler_manager.js +466 -0
- package/es/map/map.d.ts +625 -0
- package/es/map/map.js +972 -0
- package/es/map/util/abort_error.d.ts +15 -0
- package/es/map/util/abort_error.js +21 -0
- package/es/map/util/browser.d.ts +10 -0
- package/es/map/util/browser.js +30 -0
- package/es/map/util/dom.d.ts +30 -0
- package/es/map/util/dom.js +105 -0
- package/es/map/util/evented.d.ts +75 -0
- package/es/map/util/evented.js +158 -0
- package/es/map/util/task_queue.d.ts +18 -0
- package/es/map/util/task_queue.js +54 -0
- package/es/map/util/util.d.ts +104 -0
- package/es/map/util/util.js +155 -0
- package/lib/index.d.ts +3 -4
- package/lib/index.js +12 -42
- package/lib/map/camera.d.ts +690 -0
- package/lib/map/camera.js +1145 -0
- package/{es → lib/map}/css/l7.css +41 -7
- package/lib/map/events.d.ts +384 -0
- package/lib/map/events.js +231 -0
- package/lib/map/geo/edge_insets.d.ts +97 -0
- package/lib/{geo → map/geo}/edge_insets.js +56 -35
- package/lib/map/geo/lng_lat.d.ts +116 -0
- package/lib/map/geo/lng_lat.js +166 -0
- package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
- package/lib/map/geo/lng_lat_bounds.js +341 -0
- package/lib/map/geo/mercator_coordinate.d.ts +113 -0
- package/lib/map/geo/mercator_coordinate.js +157 -0
- package/lib/map/geo/transform.d.ts +262 -0
- package/lib/map/geo/transform.js +744 -0
- package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
- package/lib/map/handler/box_zoom.js +153 -0
- package/lib/map/handler/click_zoom.d.ts +24 -0
- package/lib/map/handler/click_zoom.js +54 -0
- package/lib/map/handler/cooperative_gestures.d.ts +40 -0
- package/lib/map/handler/cooperative_gestures.js +101 -0
- package/lib/map/handler/drag_handler.d.ts +88 -0
- package/lib/map/handler/drag_handler.js +97 -0
- package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
- package/lib/map/handler/drag_move_state_manager.js +103 -0
- package/lib/map/handler/handler_util.d.ts +3 -0
- package/lib/{handler → map/handler}/handler_util.js +1 -2
- package/lib/map/handler/keyboard.d.ts +88 -0
- package/lib/map/handler/keyboard.js +205 -0
- package/lib/map/handler/map_event.d.ts +46 -0
- package/lib/map/handler/map_event.js +140 -0
- package/lib/map/handler/mouse.d.ts +30 -0
- package/lib/map/handler/mouse.js +93 -0
- package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/lib/map/handler/one_finger_touch_drag.js +47 -0
- package/lib/map/handler/scroll_zoom.d.ts +102 -0
- package/lib/map/handler/scroll_zoom.js +320 -0
- package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
- package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
- package/lib/map/handler/shim/drag_pan.d.ts +79 -0
- package/lib/map/handler/shim/drag_pan.js +85 -0
- package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
- package/lib/map/handler/shim/drag_rotate.js +74 -0
- package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/lib/map/handler/shim/two_fingers_touch.js +114 -0
- package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
- package/lib/map/handler/tap_drag_zoom.js +99 -0
- package/lib/map/handler/tap_recognizer.d.ts +35 -0
- package/lib/map/handler/tap_recognizer.js +116 -0
- package/lib/map/handler/tap_zoom.d.ts +28 -0
- package/lib/map/handler/tap_zoom.js +94 -0
- package/lib/map/handler/touch_pan.d.ts +40 -0
- package/lib/map/handler/touch_pan.js +92 -0
- package/lib/map/handler/transform-provider.d.ts +23 -0
- package/lib/map/handler/transform-provider.js +43 -0
- package/lib/map/handler/two_fingers_touch.d.ts +107 -0
- package/lib/map/handler/two_fingers_touch.js +296 -0
- package/lib/map/handler_inertia.d.ts +20 -0
- package/lib/{handler → map}/handler_inertia.js +38 -53
- package/lib/map/handler_manager.d.ts +154 -0
- package/lib/map/handler_manager.js +474 -0
- package/lib/map/map.d.ts +625 -0
- package/lib/map/map.js +979 -0
- package/lib/map/util/abort_error.d.ts +15 -0
- package/lib/map/util/abort_error.js +29 -0
- package/lib/map/util/browser.d.ts +10 -0
- package/lib/map/util/browser.js +36 -0
- package/lib/map/util/dom.d.ts +30 -0
- package/lib/map/util/dom.js +113 -0
- package/lib/map/util/evented.d.ts +75 -0
- package/lib/map/util/evented.js +167 -0
- package/lib/map/util/task_queue.d.ts +18 -0
- package/lib/map/util/task_queue.js +62 -0
- package/lib/map/util/util.d.ts +104 -0
- package/lib/map/util/util.js +171 -0
- package/package.json +6 -3
- package/es/camera.d.ts +0 -86
- package/es/camera.js +0 -639
- package/es/earthmap.d.ts +0 -69
- package/es/earthmap.js +0 -445
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -59
- package/es/geo/lng_lat_bounds.d.ts +0 -25
- package/es/geo/lng_lat_bounds.js +0 -118
- package/es/geo/mercator.d.ts +0 -30
- package/es/geo/mercator.js +0 -72
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -153
- package/es/geo/simple.d.ts +0 -30
- package/es/geo/simple.js +0 -75
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -895
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -58
- package/es/handler/box_zoom.js +0 -162
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -40
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -12
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -4
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -45
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -33
- package/es/handler/events/render_event.d.ts +0 -6
- package/es/handler/events/render_event.js +0 -10
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_manager.d.ts +0 -61
- package/es/handler/handler_manager.js +0 -487
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -131
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -89
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -4
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -99
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -21
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -24
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -24
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -315
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -75
- package/es/handler/shim/drag_rotate.js +0 -64
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -104
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -77
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -89
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -46
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -81
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -5
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -91
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -75
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -57
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -37
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -98
- package/es/hash.d.ts +0 -14
- package/es/hash.js +0 -121
- package/es/interface.d.ts +0 -34
- package/es/interface.js +0 -1
- package/es/map.d.ts +0 -70
- package/es/map.js +0 -472
- package/es/util.d.ts +0 -25
- package/es/util.js +0 -70
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -72
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -117
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -58
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -37
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -60
- package/lib/camera.d.ts +0 -86
- package/lib/camera.js +0 -648
- package/lib/earthmap.d.ts +0 -69
- package/lib/earthmap.js +0 -451
- package/lib/geo/edge_insets.d.ts +0 -54
- package/lib/geo/lng_lat.d.ts +0 -18
- package/lib/geo/lng_lat.js +0 -67
- package/lib/geo/lng_lat_bounds.d.ts +0 -25
- package/lib/geo/lng_lat_bounds.js +0 -126
- package/lib/geo/mercator.d.ts +0 -30
- package/lib/geo/mercator.js +0 -88
- package/lib/geo/point.d.ts +0 -40
- package/lib/geo/point.js +0 -161
- package/lib/geo/simple.d.ts +0 -30
- package/lib/geo/simple.js +0 -92
- package/lib/geo/transform.d.ts +0 -198
- package/lib/geo/transform.js +0 -906
- package/lib/handler/IHandler.d.ts +0 -34
- package/lib/handler/IHandler.js +0 -5
- package/lib/handler/blockable_map_event.d.ts +0 -17
- package/lib/handler/blockable_map_event.js +0 -66
- package/lib/handler/box_zoom.js +0 -168
- package/lib/handler/click_zoom.d.ts +0 -16
- package/lib/handler/click_zoom.js +0 -48
- package/lib/handler/events/event.d.ts +0 -4
- package/lib/handler/events/event.js +0 -20
- package/lib/handler/events/index.d.ts +0 -4
- package/lib/handler/events/index.js +0 -27
- package/lib/handler/events/map_mouse_event.d.ts +0 -34
- package/lib/handler/events/map_mouse_event.js +0 -53
- package/lib/handler/events/map_touch_event.d.ts +0 -57
- package/lib/handler/events/map_touch_event.js +0 -83
- package/lib/handler/events/map_wheel_event.d.ts +0 -33
- package/lib/handler/events/map_wheel_event.js +0 -41
- package/lib/handler/events/render_event.d.ts +0 -6
- package/lib/handler/events/render_event.js +0 -18
- package/lib/handler/handler_inertia.d.ts +0 -23
- package/lib/handler/handler_manager.d.ts +0 -61
- package/lib/handler/handler_manager.js +0 -495
- package/lib/handler/handler_util.d.ts +0 -4
- package/lib/handler/keyboard.d.ts +0 -36
- package/lib/handler/keyboard.js +0 -138
- package/lib/handler/map_event.d.ts +0 -29
- package/lib/handler/map_event.js +0 -97
- package/lib/handler/mouse/index.d.ts +0 -4
- package/lib/handler/mouse/index.js +0 -27
- package/lib/handler/mouse/mouse_handler.d.ts +0 -22
- package/lib/handler/mouse/mouse_handler.js +0 -107
- package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
- package/lib/handler/mouse/mousepan_handler.js +0 -29
- package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/lib/handler/mouse/mousepitch_hander.js +0 -32
- package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/lib/handler/mouse/mouserotate_hander.js +0 -32
- package/lib/handler/mouse/util.d.ts +0 -6
- package/lib/handler/mouse/util.js +0 -19
- package/lib/handler/scroll_zoom.d.ts +0 -93
- package/lib/handler/scroll_zoom.js +0 -322
- package/lib/handler/shim/drag_pan.d.ts +0 -61
- package/lib/handler/shim/drag_pan.js +0 -83
- package/lib/handler/shim/drag_rotate.js +0 -72
- package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/lib/handler/shim/touch_zoom_rotate.js +0 -112
- package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/lib/handler/tap/single_tap_recognizer.js +0 -86
- package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_drag_zoom.js +0 -97
- package/lib/handler/tap/tap_recognizer.d.ts +0 -17
- package/lib/handler/tap/tap_recognizer.js +0 -56
- package/lib/handler/tap/tap_zoom.d.ts +0 -22
- package/lib/handler/tap/tap_zoom.js +0 -89
- package/lib/handler/touch/index.d.ts +0 -5
- package/lib/handler/touch/index.js +0 -34
- package/lib/handler/touch/touch_pan.d.ts +0 -30
- package/lib/handler/touch/touch_pan.js +0 -100
- package/lib/handler/touch/touch_pitch.d.ts +0 -13
- package/lib/handler/touch/touch_pitch.js +0 -83
- package/lib/handler/touch/touch_rotate.d.ts +0 -12
- package/lib/handler/touch/touch_rotate.js +0 -65
- package/lib/handler/touch/touch_zoom.d.ts +0 -12
- package/lib/handler/touch/touch_zoom.js +0 -45
- package/lib/handler/touch/two_touch.d.ts +0 -23
- package/lib/handler/touch/two_touch.js +0 -106
- package/lib/hash.d.ts +0 -14
- package/lib/hash.js +0 -129
- package/lib/interface.d.ts +0 -34
- package/lib/interface.js +0 -5
- package/lib/map.d.ts +0 -70
- package/lib/map.js +0 -478
- package/lib/util.d.ts +0 -25
- package/lib/util.js +0 -89
- package/lib/utils/Aabb.d.ts +0 -12
- package/lib/utils/Aabb.js +0 -80
- package/lib/utils/dom.d.ts +0 -4
- package/lib/utils/dom.js +0 -125
- package/lib/utils/performance.d.ts +0 -17
- package/lib/utils/performance.js +0 -64
- package/lib/utils/primitives.d.ts +0 -6
- package/lib/utils/primitives.js +0 -45
- package/lib/utils/task_queue.d.ts +0 -13
- package/lib/utils/task_queue.js +0 -67
|
@@ -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
|
+
};
|
|
@@ -4,27 +4,34 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.EdgeInsets = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
|
|
9
|
+
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
10
|
+
var _util = require("../util/util");
|
|
13
11
|
/**
|
|
14
12
|
* An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
|
|
15
13
|
* This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
|
|
16
14
|
* on top of the map and having the vanishing point shift as UI elements resize.
|
|
17
15
|
*
|
|
18
|
-
* @
|
|
19
|
-
* @param {number} [bottom=0]
|
|
20
|
-
* @param {number} [left=0]
|
|
21
|
-
* @param {number} [right=0]
|
|
16
|
+
* @group Geography and Geometry
|
|
22
17
|
*/
|
|
23
18
|
class EdgeInsets {
|
|
24
19
|
constructor(top = 0, bottom = 0, left = 0, right = 0) {
|
|
20
|
+
/**
|
|
21
|
+
* @defaultValue 0
|
|
22
|
+
*/
|
|
25
23
|
(0, _defineProperty2.default)(this, "top", void 0);
|
|
24
|
+
/**
|
|
25
|
+
* @defaultValue 0
|
|
26
|
+
*/
|
|
26
27
|
(0, _defineProperty2.default)(this, "bottom", void 0);
|
|
28
|
+
/**
|
|
29
|
+
* @defaultValue 0
|
|
30
|
+
*/
|
|
27
31
|
(0, _defineProperty2.default)(this, "left", void 0);
|
|
32
|
+
/**
|
|
33
|
+
* @defaultValue 0
|
|
34
|
+
*/
|
|
28
35
|
(0, _defineProperty2.default)(this, "right", void 0);
|
|
29
36
|
if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
|
|
30
37
|
throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
|
|
@@ -38,25 +45,16 @@ class EdgeInsets {
|
|
|
38
45
|
/**
|
|
39
46
|
* Interpolates the inset in-place.
|
|
40
47
|
* This maintains the current inset value for any inset not present in `target`.
|
|
41
|
-
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
45
|
-
* @memberof EdgeInsets
|
|
48
|
+
* @param start - interpolation start
|
|
49
|
+
* @param target - interpolation target
|
|
50
|
+
* @param t - interpolation step/weight
|
|
51
|
+
* @returns the insets
|
|
46
52
|
*/
|
|
47
53
|
interpolate(start, target, t) {
|
|
48
|
-
if (target.top != null && start.top != null)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (target.
|
|
52
|
-
this.bottom = (0, _util.interpolate)(start.bottom, target.bottom, t);
|
|
53
|
-
}
|
|
54
|
-
if (target.left != null && start.left != null) {
|
|
55
|
-
this.left = (0, _util.interpolate)(start.left, target.left, t);
|
|
56
|
-
}
|
|
57
|
-
if (target.right != null && start.right != null) {
|
|
58
|
-
this.right = (0, _util.interpolate)(start.right, target.right, t);
|
|
59
|
-
}
|
|
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);
|
|
60
58
|
return this;
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -64,16 +62,15 @@ class EdgeInsets {
|
|
|
64
62
|
* Utility method that computes the new apprent center or vanishing point after applying insets.
|
|
65
63
|
* This is in pixels and with the top left being (0.0) and +y being downwards.
|
|
66
64
|
*
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
* @returns
|
|
70
|
-
* @memberof EdgeInsets
|
|
65
|
+
* @param width - the width
|
|
66
|
+
* @param height - the height
|
|
67
|
+
* @returns the point
|
|
71
68
|
*/
|
|
72
69
|
getCenter(width, height) {
|
|
73
70
|
// Clamp insets so they never overflow width/height and always calculate a valid center
|
|
74
71
|
const x = (0, _util.clamp)((this.left + width - this.right) / 2, 0, width);
|
|
75
72
|
const y = (0, _util.clamp)((this.top + height - this.bottom) / 2, 0, height);
|
|
76
|
-
return new
|
|
73
|
+
return new _pointGeometry.default(x, y);
|
|
77
74
|
}
|
|
78
75
|
equals(other) {
|
|
79
76
|
return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
|
|
@@ -83,11 +80,10 @@ class EdgeInsets {
|
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
/**
|
|
86
|
-
* Returns the current
|
|
83
|
+
* Returns the current state as json, useful when you want to have a
|
|
87
84
|
* read-only representation of the inset.
|
|
88
85
|
*
|
|
89
|
-
* @returns
|
|
90
|
-
* @memberof EdgeInsets
|
|
86
|
+
* @returns state as json
|
|
91
87
|
*/
|
|
92
88
|
toJSON() {
|
|
93
89
|
return {
|
|
@@ -98,4 +94,29 @@ class EdgeInsets {
|
|
|
98
94
|
};
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
|
|
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
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.earthRadius = exports.LngLat = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _util = require("../util/util");
|
|
10
|
+
/*
|
|
11
|
+
* Approximate radius of the earth in meters.
|
|
12
|
+
* 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
|
|
13
|
+
* 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
|
|
14
|
+
*/
|
|
15
|
+
const earthRadius = exports.earthRadius = 6371008.8;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A {@link LngLat} object, an array of two numbers representing longitude and latitude,
|
|
19
|
+
* or an object with `lng` and `lat` or `lon` and `lat` properties.
|
|
20
|
+
*
|
|
21
|
+
* @group Geography and Geometry
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* let v1 = new LngLat(-122.420679, 37.772537);
|
|
26
|
+
* let v2 = [-122.420679, 37.772537];
|
|
27
|
+
* let v3 = {lon: -122.420679, lat: 37.772537};
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
|
|
33
|
+
* These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
|
|
34
|
+
*
|
|
35
|
+
* MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
|
|
36
|
+
* [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
|
|
37
|
+
*
|
|
38
|
+
* Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option
|
|
39
|
+
* can also accept an `Array` of two numbers and will perform an implicit conversion.
|
|
40
|
+
* This flexible type is documented as {@link LngLatLike}.
|
|
41
|
+
*
|
|
42
|
+
* @group Geography and Geometry
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* let ll = new LngLat(-123.9749, 40.7736);
|
|
47
|
+
* ll.lng; // = -123.9749
|
|
48
|
+
* ```
|
|
49
|
+
* @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
|
|
50
|
+
* @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)
|
|
51
|
+
* @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)
|
|
52
|
+
*/
|
|
53
|
+
class LngLat {
|
|
54
|
+
/**
|
|
55
|
+
* @param lng - Longitude, measured in degrees.
|
|
56
|
+
* @param lat - Latitude, measured in degrees.
|
|
57
|
+
*/
|
|
58
|
+
constructor(lng, lat) {
|
|
59
|
+
(0, _defineProperty2.default)(this, "lng", void 0);
|
|
60
|
+
(0, _defineProperty2.default)(this, "lat", void 0);
|
|
61
|
+
if (isNaN(lng) || isNaN(lat)) {
|
|
62
|
+
throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
|
|
63
|
+
}
|
|
64
|
+
this.lng = +lng;
|
|
65
|
+
this.lat = +lat;
|
|
66
|
+
if (this.lat > 90 || this.lat < -90) {
|
|
67
|
+
throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
|
|
73
|
+
*
|
|
74
|
+
* @returns The wrapped `LngLat` object.
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* let ll = new LngLat(286.0251, 40.7736);
|
|
78
|
+
* let wrapped = ll.wrap();
|
|
79
|
+
* wrapped.lng; // = -73.9749
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
wrap() {
|
|
83
|
+
return new LngLat((0, _util.wrap)(this.lng, -180, 180), this.lat);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns the coordinates represented as an array of two numbers.
|
|
88
|
+
*
|
|
89
|
+
* @returns The coordinates represented as an array of longitude and latitude.
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* let ll = new LngLat(-73.9749, 40.7736);
|
|
93
|
+
* ll.toArray(); // = [-73.9749, 40.7736]
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
toArray() {
|
|
97
|
+
return [this.lng, this.lat];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns the coordinates represent as a string.
|
|
102
|
+
*
|
|
103
|
+
* @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* let ll = new LngLat(-73.9749, 40.7736);
|
|
107
|
+
* ll.toString(); // = "LngLat(-73.9749, 40.7736)"
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
toString() {
|
|
111
|
+
return `LngLat(${this.lng}, ${this.lat})`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Returns the approximate distance between a pair of coordinates in meters
|
|
116
|
+
* Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
|
|
117
|
+
*
|
|
118
|
+
* @param lngLat - coordinates to compute the distance to
|
|
119
|
+
* @returns Distance in meters between the two coordinates.
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* let new_york = new LngLat(-74.0060, 40.7128);
|
|
123
|
+
* let los_angeles = new LngLat(-118.2437, 34.0522);
|
|
124
|
+
* new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
distanceTo(lngLat) {
|
|
128
|
+
const rad = Math.PI / 180;
|
|
129
|
+
const lat1 = this.lat * rad;
|
|
130
|
+
const lat2 = lngLat.lat * rad;
|
|
131
|
+
const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
|
|
132
|
+
const maxMeters = earthRadius * Math.acos(Math.min(a, 1));
|
|
133
|
+
return maxMeters;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties
|
|
138
|
+
* to a `LngLat` object.
|
|
139
|
+
*
|
|
140
|
+
* If a `LngLat` object is passed in, the function returns it unchanged.
|
|
141
|
+
*
|
|
142
|
+
* @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
|
|
143
|
+
* @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* let arr = [-73.9749, 40.7736];
|
|
147
|
+
* let ll = LngLat.convert(arr);
|
|
148
|
+
* ll; // = LngLat {lng: -73.9749, lat: 40.7736}
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
static convert(input) {
|
|
152
|
+
if (input instanceof LngLat) {
|
|
153
|
+
return input;
|
|
154
|
+
}
|
|
155
|
+
if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
|
|
156
|
+
return new LngLat(Number(input[0]), Number(input[1]));
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(input) && typeof input === 'object' && input !== null) {
|
|
159
|
+
return new LngLat(
|
|
160
|
+
// flow can't refine this to have one of lng or lat, so we have to cast to any
|
|
161
|
+
Number('lng' in input ? input.lng : input.lon), Number(input.lat));
|
|
162
|
+
}
|
|
163
|
+
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>]');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.LngLat = LngLat;
|