@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.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 (358) hide show
  1. package/README.md +27 -6
  2. package/es/index.d.ts +3 -4
  3. package/es/index.js +2 -4
  4. package/es/map/camera.d.ts +690 -0
  5. package/es/map/camera.js +1138 -0
  6. package/{lib → es/map}/css/l7.css +41 -7
  7. package/es/map/events.d.ts +384 -0
  8. package/es/map/events.js +222 -0
  9. package/es/map/geo/edge_insets.d.ts +97 -0
  10. package/es/{geo → map/geo}/edge_insets.js +55 -33
  11. package/es/map/geo/lng_lat.d.ts +116 -0
  12. package/es/map/geo/lng_lat.js +159 -0
  13. package/es/map/geo/lng_lat_bounds.d.ts +217 -0
  14. package/es/map/geo/lng_lat_bounds.js +334 -0
  15. package/es/map/geo/mercator_coordinate.d.ts +113 -0
  16. package/es/map/geo/mercator_coordinate.js +142 -0
  17. package/es/map/geo/transform.d.ts +262 -0
  18. package/es/map/geo/transform.js +736 -0
  19. package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
  20. package/es/map/handler/box_zoom.js +145 -0
  21. package/es/map/handler/click_zoom.d.ts +24 -0
  22. package/es/map/handler/click_zoom.js +47 -0
  23. package/es/map/handler/cooperative_gestures.d.ts +40 -0
  24. package/es/map/handler/cooperative_gestures.js +94 -0
  25. package/es/map/handler/drag_handler.d.ts +88 -0
  26. package/es/map/handler/drag_handler.js +89 -0
  27. package/es/map/handler/drag_move_state_manager.d.ts +30 -0
  28. package/es/map/handler/drag_move_state_manager.js +94 -0
  29. package/es/map/handler/handler_util.d.ts +3 -0
  30. package/es/{handler → map/handler}/handler_util.js +1 -2
  31. package/es/map/handler/keyboard.d.ts +88 -0
  32. package/es/map/handler/keyboard.js +197 -0
  33. package/es/map/handler/map_event.d.ts +46 -0
  34. package/es/map/handler/map_event.js +131 -0
  35. package/es/map/handler/mouse.d.ts +30 -0
  36. package/es/map/handler/mouse.js +85 -0
  37. package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
  38. package/es/map/handler/one_finger_touch_drag.js +39 -0
  39. package/es/map/handler/scroll_zoom.d.ts +102 -0
  40. package/es/map/handler/scroll_zoom.js +312 -0
  41. package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  42. package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
  43. package/es/map/handler/shim/drag_pan.d.ts +79 -0
  44. package/es/map/handler/shim/drag_pan.js +77 -0
  45. package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  46. package/es/map/handler/shim/drag_rotate.js +66 -0
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
  48. package/es/map/handler/shim/two_fingers_touch.js +106 -0
  49. package/es/map/handler/tap_drag_zoom.d.ts +28 -0
  50. package/es/map/handler/tap_drag_zoom.js +92 -0
  51. package/es/map/handler/tap_recognizer.d.ts +35 -0
  52. package/es/map/handler/tap_recognizer.js +107 -0
  53. package/es/map/handler/tap_zoom.d.ts +28 -0
  54. package/es/map/handler/tap_zoom.js +87 -0
  55. package/es/map/handler/touch_pan.d.ts +40 -0
  56. package/es/map/handler/touch_pan.js +85 -0
  57. package/es/map/handler/transform-provider.d.ts +23 -0
  58. package/es/map/handler/transform-provider.js +35 -0
  59. package/es/map/handler/two_fingers_touch.d.ts +107 -0
  60. package/es/map/handler/two_fingers_touch.js +289 -0
  61. package/es/map/handler_inertia.d.ts +20 -0
  62. package/es/{handler → map}/handler_inertia.js +36 -50
  63. package/es/map/handler_manager.d.ts +154 -0
  64. package/es/map/handler_manager.js +466 -0
  65. package/es/map/map.d.ts +625 -0
  66. package/es/map/map.js +972 -0
  67. package/es/map/util/abort_error.d.ts +15 -0
  68. package/es/map/util/abort_error.js +21 -0
  69. package/es/map/util/browser.d.ts +10 -0
  70. package/es/map/util/browser.js +30 -0
  71. package/es/map/util/dom.d.ts +30 -0
  72. package/es/map/util/dom.js +105 -0
  73. package/es/map/util/evented.d.ts +75 -0
  74. package/es/map/util/evented.js +158 -0
  75. package/es/map/util/task_queue.d.ts +18 -0
  76. package/es/map/util/task_queue.js +54 -0
  77. package/es/map/util/util.d.ts +104 -0
  78. package/es/map/util/util.js +155 -0
  79. package/lib/index.d.ts +3 -4
  80. package/lib/index.js +12 -42
  81. package/lib/map/camera.d.ts +690 -0
  82. package/lib/map/camera.js +1145 -0
  83. package/{es → lib/map}/css/l7.css +41 -7
  84. package/lib/map/events.d.ts +384 -0
  85. package/lib/map/events.js +231 -0
  86. package/lib/map/geo/edge_insets.d.ts +97 -0
  87. package/lib/{geo → map/geo}/edge_insets.js +56 -35
  88. package/lib/map/geo/lng_lat.d.ts +116 -0
  89. package/lib/map/geo/lng_lat.js +166 -0
  90. package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
  91. package/lib/map/geo/lng_lat_bounds.js +341 -0
  92. package/lib/map/geo/mercator_coordinate.d.ts +113 -0
  93. package/lib/map/geo/mercator_coordinate.js +157 -0
  94. package/lib/map/geo/transform.d.ts +262 -0
  95. package/lib/map/geo/transform.js +744 -0
  96. package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
  97. package/lib/map/handler/box_zoom.js +153 -0
  98. package/lib/map/handler/click_zoom.d.ts +24 -0
  99. package/lib/map/handler/click_zoom.js +54 -0
  100. package/lib/map/handler/cooperative_gestures.d.ts +40 -0
  101. package/lib/map/handler/cooperative_gestures.js +101 -0
  102. package/lib/map/handler/drag_handler.d.ts +88 -0
  103. package/lib/map/handler/drag_handler.js +97 -0
  104. package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
  105. package/lib/map/handler/drag_move_state_manager.js +103 -0
  106. package/lib/map/handler/handler_util.d.ts +3 -0
  107. package/lib/{handler → map/handler}/handler_util.js +1 -2
  108. package/lib/map/handler/keyboard.d.ts +88 -0
  109. package/lib/map/handler/keyboard.js +205 -0
  110. package/lib/map/handler/map_event.d.ts +46 -0
  111. package/lib/map/handler/map_event.js +140 -0
  112. package/lib/map/handler/mouse.d.ts +30 -0
  113. package/lib/map/handler/mouse.js +93 -0
  114. package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
  115. package/lib/map/handler/one_finger_touch_drag.js +47 -0
  116. package/lib/map/handler/scroll_zoom.d.ts +102 -0
  117. package/lib/map/handler/scroll_zoom.js +320 -0
  118. package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  119. package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
  120. package/lib/map/handler/shim/drag_pan.d.ts +79 -0
  121. package/lib/map/handler/shim/drag_pan.js +85 -0
  122. package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  123. package/lib/map/handler/shim/drag_rotate.js +74 -0
  124. package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
  125. package/lib/map/handler/shim/two_fingers_touch.js +114 -0
  126. package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
  127. package/lib/map/handler/tap_drag_zoom.js +99 -0
  128. package/lib/map/handler/tap_recognizer.d.ts +35 -0
  129. package/lib/map/handler/tap_recognizer.js +116 -0
  130. package/lib/map/handler/tap_zoom.d.ts +28 -0
  131. package/lib/map/handler/tap_zoom.js +94 -0
  132. package/lib/map/handler/touch_pan.d.ts +40 -0
  133. package/lib/map/handler/touch_pan.js +92 -0
  134. package/lib/map/handler/transform-provider.d.ts +23 -0
  135. package/lib/map/handler/transform-provider.js +43 -0
  136. package/lib/map/handler/two_fingers_touch.d.ts +107 -0
  137. package/lib/map/handler/two_fingers_touch.js +296 -0
  138. package/lib/map/handler_inertia.d.ts +20 -0
  139. package/lib/{handler → map}/handler_inertia.js +38 -53
  140. package/lib/map/handler_manager.d.ts +154 -0
  141. package/lib/map/handler_manager.js +474 -0
  142. package/lib/map/map.d.ts +625 -0
  143. package/lib/map/map.js +979 -0
  144. package/lib/map/util/abort_error.d.ts +15 -0
  145. package/lib/map/util/abort_error.js +29 -0
  146. package/lib/map/util/browser.d.ts +10 -0
  147. package/lib/map/util/browser.js +36 -0
  148. package/lib/map/util/dom.d.ts +30 -0
  149. package/lib/map/util/dom.js +113 -0
  150. package/lib/map/util/evented.d.ts +75 -0
  151. package/lib/map/util/evented.js +167 -0
  152. package/lib/map/util/task_queue.d.ts +18 -0
  153. package/lib/map/util/task_queue.js +62 -0
  154. package/lib/map/util/util.d.ts +104 -0
  155. package/lib/map/util/util.js +171 -0
  156. package/package.json +6 -3
  157. package/es/camera.d.ts +0 -86
  158. package/es/camera.js +0 -639
  159. package/es/earthmap.d.ts +0 -69
  160. package/es/earthmap.js +0 -445
  161. package/es/geo/edge_insets.d.ts +0 -54
  162. package/es/geo/lng_lat.d.ts +0 -18
  163. package/es/geo/lng_lat.js +0 -59
  164. package/es/geo/lng_lat_bounds.d.ts +0 -25
  165. package/es/geo/lng_lat_bounds.js +0 -118
  166. package/es/geo/mercator.d.ts +0 -30
  167. package/es/geo/mercator.js +0 -72
  168. package/es/geo/point.d.ts +0 -40
  169. package/es/geo/point.js +0 -153
  170. package/es/geo/simple.d.ts +0 -30
  171. package/es/geo/simple.js +0 -75
  172. package/es/geo/transform.d.ts +0 -198
  173. package/es/geo/transform.js +0 -895
  174. package/es/handler/IHandler.d.ts +0 -34
  175. package/es/handler/IHandler.js +0 -1
  176. package/es/handler/blockable_map_event.d.ts +0 -17
  177. package/es/handler/blockable_map_event.js +0 -58
  178. package/es/handler/box_zoom.js +0 -162
  179. package/es/handler/click_zoom.d.ts +0 -16
  180. package/es/handler/click_zoom.js +0 -40
  181. package/es/handler/events/event.d.ts +0 -4
  182. package/es/handler/events/event.js +0 -12
  183. package/es/handler/events/index.d.ts +0 -4
  184. package/es/handler/events/index.js +0 -4
  185. package/es/handler/events/map_mouse_event.d.ts +0 -34
  186. package/es/handler/events/map_mouse_event.js +0 -45
  187. package/es/handler/events/map_touch_event.d.ts +0 -57
  188. package/es/handler/events/map_touch_event.js +0 -75
  189. package/es/handler/events/map_wheel_event.d.ts +0 -33
  190. package/es/handler/events/map_wheel_event.js +0 -33
  191. package/es/handler/events/render_event.d.ts +0 -6
  192. package/es/handler/events/render_event.js +0 -10
  193. package/es/handler/handler_inertia.d.ts +0 -23
  194. package/es/handler/handler_manager.d.ts +0 -61
  195. package/es/handler/handler_manager.js +0 -487
  196. package/es/handler/handler_util.d.ts +0 -4
  197. package/es/handler/keyboard.d.ts +0 -36
  198. package/es/handler/keyboard.js +0 -131
  199. package/es/handler/map_event.d.ts +0 -29
  200. package/es/handler/map_event.js +0 -89
  201. package/es/handler/mouse/index.d.ts +0 -4
  202. package/es/handler/mouse/index.js +0 -4
  203. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  204. package/es/handler/mouse/mouse_handler.js +0 -99
  205. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  206. package/es/handler/mouse/mousepan_handler.js +0 -21
  207. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  208. package/es/handler/mouse/mousepitch_hander.js +0 -24
  209. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  210. package/es/handler/mouse/mouserotate_hander.js +0 -24
  211. package/es/handler/mouse/util.d.ts +0 -6
  212. package/es/handler/mouse/util.js +0 -12
  213. package/es/handler/scroll_zoom.d.ts +0 -93
  214. package/es/handler/scroll_zoom.js +0 -315
  215. package/es/handler/shim/drag_pan.d.ts +0 -61
  216. package/es/handler/shim/drag_pan.js +0 -75
  217. package/es/handler/shim/drag_rotate.js +0 -64
  218. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  219. package/es/handler/shim/touch_zoom_rotate.js +0 -104
  220. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  221. package/es/handler/tap/single_tap_recognizer.js +0 -77
  222. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  223. package/es/handler/tap/tap_drag_zoom.js +0 -89
  224. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  225. package/es/handler/tap/tap_recognizer.js +0 -46
  226. package/es/handler/tap/tap_zoom.d.ts +0 -22
  227. package/es/handler/tap/tap_zoom.js +0 -81
  228. package/es/handler/touch/index.d.ts +0 -5
  229. package/es/handler/touch/index.js +0 -5
  230. package/es/handler/touch/touch_pan.d.ts +0 -30
  231. package/es/handler/touch/touch_pan.js +0 -91
  232. package/es/handler/touch/touch_pitch.d.ts +0 -13
  233. package/es/handler/touch/touch_pitch.js +0 -75
  234. package/es/handler/touch/touch_rotate.d.ts +0 -12
  235. package/es/handler/touch/touch_rotate.js +0 -57
  236. package/es/handler/touch/touch_zoom.d.ts +0 -12
  237. package/es/handler/touch/touch_zoom.js +0 -37
  238. package/es/handler/touch/two_touch.d.ts +0 -23
  239. package/es/handler/touch/two_touch.js +0 -98
  240. package/es/hash.d.ts +0 -14
  241. package/es/hash.js +0 -121
  242. package/es/interface.d.ts +0 -34
  243. package/es/interface.js +0 -1
  244. package/es/map.d.ts +0 -70
  245. package/es/map.js +0 -472
  246. package/es/util.d.ts +0 -25
  247. package/es/util.js +0 -70
  248. package/es/utils/Aabb.d.ts +0 -12
  249. package/es/utils/Aabb.js +0 -72
  250. package/es/utils/dom.d.ts +0 -4
  251. package/es/utils/dom.js +0 -117
  252. package/es/utils/performance.d.ts +0 -17
  253. package/es/utils/performance.js +0 -58
  254. package/es/utils/primitives.d.ts +0 -6
  255. package/es/utils/primitives.js +0 -37
  256. package/es/utils/task_queue.d.ts +0 -13
  257. package/es/utils/task_queue.js +0 -60
  258. package/lib/camera.d.ts +0 -86
  259. package/lib/camera.js +0 -648
  260. package/lib/earthmap.d.ts +0 -69
  261. package/lib/earthmap.js +0 -451
  262. package/lib/geo/edge_insets.d.ts +0 -54
  263. package/lib/geo/lng_lat.d.ts +0 -18
  264. package/lib/geo/lng_lat.js +0 -67
  265. package/lib/geo/lng_lat_bounds.d.ts +0 -25
  266. package/lib/geo/lng_lat_bounds.js +0 -126
  267. package/lib/geo/mercator.d.ts +0 -30
  268. package/lib/geo/mercator.js +0 -88
  269. package/lib/geo/point.d.ts +0 -40
  270. package/lib/geo/point.js +0 -161
  271. package/lib/geo/simple.d.ts +0 -30
  272. package/lib/geo/simple.js +0 -92
  273. package/lib/geo/transform.d.ts +0 -198
  274. package/lib/geo/transform.js +0 -906
  275. package/lib/handler/IHandler.d.ts +0 -34
  276. package/lib/handler/IHandler.js +0 -5
  277. package/lib/handler/blockable_map_event.d.ts +0 -17
  278. package/lib/handler/blockable_map_event.js +0 -66
  279. package/lib/handler/box_zoom.js +0 -168
  280. package/lib/handler/click_zoom.d.ts +0 -16
  281. package/lib/handler/click_zoom.js +0 -48
  282. package/lib/handler/events/event.d.ts +0 -4
  283. package/lib/handler/events/event.js +0 -20
  284. package/lib/handler/events/index.d.ts +0 -4
  285. package/lib/handler/events/index.js +0 -27
  286. package/lib/handler/events/map_mouse_event.d.ts +0 -34
  287. package/lib/handler/events/map_mouse_event.js +0 -53
  288. package/lib/handler/events/map_touch_event.d.ts +0 -57
  289. package/lib/handler/events/map_touch_event.js +0 -83
  290. package/lib/handler/events/map_wheel_event.d.ts +0 -33
  291. package/lib/handler/events/map_wheel_event.js +0 -41
  292. package/lib/handler/events/render_event.d.ts +0 -6
  293. package/lib/handler/events/render_event.js +0 -18
  294. package/lib/handler/handler_inertia.d.ts +0 -23
  295. package/lib/handler/handler_manager.d.ts +0 -61
  296. package/lib/handler/handler_manager.js +0 -495
  297. package/lib/handler/handler_util.d.ts +0 -4
  298. package/lib/handler/keyboard.d.ts +0 -36
  299. package/lib/handler/keyboard.js +0 -138
  300. package/lib/handler/map_event.d.ts +0 -29
  301. package/lib/handler/map_event.js +0 -97
  302. package/lib/handler/mouse/index.d.ts +0 -4
  303. package/lib/handler/mouse/index.js +0 -27
  304. package/lib/handler/mouse/mouse_handler.d.ts +0 -22
  305. package/lib/handler/mouse/mouse_handler.js +0 -107
  306. package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
  307. package/lib/handler/mouse/mousepan_handler.js +0 -29
  308. package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
  309. package/lib/handler/mouse/mousepitch_hander.js +0 -32
  310. package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
  311. package/lib/handler/mouse/mouserotate_hander.js +0 -32
  312. package/lib/handler/mouse/util.d.ts +0 -6
  313. package/lib/handler/mouse/util.js +0 -19
  314. package/lib/handler/scroll_zoom.d.ts +0 -93
  315. package/lib/handler/scroll_zoom.js +0 -322
  316. package/lib/handler/shim/drag_pan.d.ts +0 -61
  317. package/lib/handler/shim/drag_pan.js +0 -83
  318. package/lib/handler/shim/drag_rotate.js +0 -72
  319. package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
  320. package/lib/handler/shim/touch_zoom_rotate.js +0 -112
  321. package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
  322. package/lib/handler/tap/single_tap_recognizer.js +0 -86
  323. package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
  324. package/lib/handler/tap/tap_drag_zoom.js +0 -97
  325. package/lib/handler/tap/tap_recognizer.d.ts +0 -17
  326. package/lib/handler/tap/tap_recognizer.js +0 -56
  327. package/lib/handler/tap/tap_zoom.d.ts +0 -22
  328. package/lib/handler/tap/tap_zoom.js +0 -89
  329. package/lib/handler/touch/index.d.ts +0 -5
  330. package/lib/handler/touch/index.js +0 -34
  331. package/lib/handler/touch/touch_pan.d.ts +0 -30
  332. package/lib/handler/touch/touch_pan.js +0 -100
  333. package/lib/handler/touch/touch_pitch.d.ts +0 -13
  334. package/lib/handler/touch/touch_pitch.js +0 -83
  335. package/lib/handler/touch/touch_rotate.d.ts +0 -12
  336. package/lib/handler/touch/touch_rotate.js +0 -65
  337. package/lib/handler/touch/touch_zoom.d.ts +0 -12
  338. package/lib/handler/touch/touch_zoom.js +0 -45
  339. package/lib/handler/touch/two_touch.d.ts +0 -23
  340. package/lib/handler/touch/two_touch.js +0 -106
  341. package/lib/hash.d.ts +0 -14
  342. package/lib/hash.js +0 -129
  343. package/lib/interface.d.ts +0 -34
  344. package/lib/interface.js +0 -5
  345. package/lib/map.d.ts +0 -70
  346. package/lib/map.js +0 -478
  347. package/lib/util.d.ts +0 -25
  348. package/lib/util.js +0 -89
  349. package/lib/utils/Aabb.d.ts +0 -12
  350. package/lib/utils/Aabb.js +0 -80
  351. package/lib/utils/dom.d.ts +0 -4
  352. package/lib/utils/dom.js +0 -125
  353. package/lib/utils/performance.d.ts +0 -17
  354. package/lib/utils/performance.js +0 -64
  355. package/lib/utils/primitives.d.ts +0 -6
  356. package/lib/utils/primitives.js +0 -45
  357. package/lib/utils/task_queue.d.ts +0 -13
  358. 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
+ };
@@ -1,23 +1,31 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- // @ts-ignore
3
- import { clamp, interpolate } from "../util";
4
- import Point from "./point";
2
+ import Point from '@mapbox/point-geometry';
3
+ import { clamp, interpolates } from "../util/util";
5
4
 
6
5
  /**
7
6
  * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
8
7
  * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
9
8
  * on top of the map and having the vanishing point shift as UI elements resize.
10
9
  *
11
- * @param {number} [top=0]
12
- * @param {number} [bottom=0]
13
- * @param {number} [left=0]
14
- * @param {number} [right=0]
10
+ * @group Geography and Geometry
15
11
  */
16
- export default class EdgeInsets {
12
+ export class EdgeInsets {
17
13
  constructor(top = 0, bottom = 0, left = 0, right = 0) {
14
+ /**
15
+ * @defaultValue 0
16
+ */
18
17
  _defineProperty(this, "top", void 0);
18
+ /**
19
+ * @defaultValue 0
20
+ */
19
21
  _defineProperty(this, "bottom", void 0);
22
+ /**
23
+ * @defaultValue 0
24
+ */
20
25
  _defineProperty(this, "left", void 0);
26
+ /**
27
+ * @defaultValue 0
28
+ */
21
29
  _defineProperty(this, "right", void 0);
22
30
  if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
23
31
  throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
@@ -31,25 +39,16 @@ export default class EdgeInsets {
31
39
  /**
32
40
  * Interpolates the inset in-place.
33
41
  * This maintains the current inset value for any inset not present in `target`.
34
- *
35
- * @param {PaddingOptions} target
36
- * @param {number} t
37
- * @returns {EdgeInsets}
38
- * @memberof EdgeInsets
42
+ * @param start - interpolation start
43
+ * @param target - interpolation target
44
+ * @param t - interpolation step/weight
45
+ * @returns the insets
39
46
  */
40
47
  interpolate(start, target, t) {
41
- if (target.top != null && start.top != null) {
42
- this.top = interpolate(start.top, target.top, t);
43
- }
44
- if (target.bottom != null && start.bottom != null) {
45
- this.bottom = interpolate(start.bottom, target.bottom, t);
46
- }
47
- if (target.left != null && start.left != null) {
48
- this.left = interpolate(start.left, target.left, t);
49
- }
50
- if (target.right != null && start.right != null) {
51
- this.right = interpolate(start.right, target.right, t);
52
- }
48
+ if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t);
49
+ if (target.bottom != null && start.bottom != null) this.bottom = interpolates.number(start.bottom, target.bottom, t);
50
+ if (target.left != null && start.left != null) this.left = interpolates.number(start.left, target.left, t);
51
+ if (target.right != null && start.right != null) this.right = interpolates.number(start.right, target.right, t);
53
52
  return this;
54
53
  }
55
54
 
@@ -57,10 +56,9 @@ export default class EdgeInsets {
57
56
  * Utility method that computes the new apprent center or vanishing point after applying insets.
58
57
  * This is in pixels and with the top left being (0.0) and +y being downwards.
59
58
  *
60
- * @param {number} width
61
- * @param {number} height
62
- * @returns {Point}
63
- * @memberof EdgeInsets
59
+ * @param width - the width
60
+ * @param height - the height
61
+ * @returns the point
64
62
  */
65
63
  getCenter(width, height) {
66
64
  // Clamp insets so they never overflow width/height and always calculate a valid center
@@ -76,11 +74,10 @@ export default class EdgeInsets {
76
74
  }
77
75
 
78
76
  /**
79
- * Returns the current sdtate as json, useful when you want to have a
77
+ * Returns the current state as json, useful when you want to have a
80
78
  * read-only representation of the inset.
81
79
  *
82
- * @returns {PaddingOptions}
83
- * @memberof EdgeInsets
80
+ * @returns state as json
84
81
  */
85
82
  toJSON() {
86
83
  return {
@@ -90,4 +87,29 @@ export default class EdgeInsets {
90
87
  right: this.right
91
88
  };
92
89
  }
93
- }
90
+ }
91
+
92
+ /**
93
+ * 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
94
+ * non-negative integers.
95
+ *
96
+ * @group Geography and Geometry
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * let bbox = [[-79, 43], [-73, 45]];
101
+ * map.fitBounds(bbox, {
102
+ * padding: {top: 10, bottom:25, left: 15, right: 5}
103
+ * });
104
+ * ```
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * let bbox = [[-79, 43], [-73, 45]];
109
+ * map.fitBounds(bbox, {
110
+ * padding: 20
111
+ * });
112
+ * ```
113
+ * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)
114
+ * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)
115
+ */
@@ -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,159 @@
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
+ }