maplibre-gl 3.1.0 → 3.2.0-pre.2

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 (338) hide show
  1. package/README.md +7 -7
  2. package/build/generate-doc-images.ts +73 -0
  3. package/build/generate-docs.ts +100 -0
  4. package/build/generate-struct-arrays.ts +9 -12
  5. package/dist/maplibre-gl-csp-worker.js +1 -1
  6. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  7. package/dist/maplibre-gl-csp.js +1 -1
  8. package/dist/maplibre-gl-csp.js.map +1 -1
  9. package/dist/maplibre-gl-dev.js +3303 -3398
  10. package/dist/maplibre-gl-dev.js.map +1 -1
  11. package/dist/maplibre-gl.d.ts +3899 -3531
  12. package/dist/maplibre-gl.js +3 -3
  13. package/dist/maplibre-gl.js.map +1 -1
  14. package/package.json +28 -25
  15. package/src/data/array_types.g.ts +14 -48
  16. package/src/data/bucket/circle_bucket.ts +11 -14
  17. package/src/data/bucket/fill_bucket.test.ts +6 -6
  18. package/src/data/bucket/fill_bucket.ts +10 -12
  19. package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
  20. package/src/data/bucket/heatmap_bucket.ts +3 -6
  21. package/src/data/bucket/line_attributes.ts +1 -2
  22. package/src/data/bucket/line_attributes_ext.ts +1 -2
  23. package/src/data/bucket/line_bucket.test.ts +5 -5
  24. package/src/data/bucket/line_bucket.ts +18 -21
  25. package/src/data/bucket/pattern_attributes.ts +1 -3
  26. package/src/data/bucket/pattern_bucket_features.ts +3 -3
  27. package/src/data/bucket/symbol_bucket.test.ts +5 -5
  28. package/src/data/bucket/symbol_bucket.ts +12 -15
  29. package/src/data/bucket.ts +7 -11
  30. package/src/data/dem_data.test.ts +1 -1
  31. package/src/data/dem_data.ts +1 -1
  32. package/src/data/evaluation_feature.ts +4 -5
  33. package/src/data/extent.ts +1 -4
  34. package/src/data/feature_index.ts +14 -13
  35. package/src/data/feature_position_map.test.ts +4 -4
  36. package/src/data/feature_position_map.ts +1 -1
  37. package/src/data/index_array_type.ts +0 -1
  38. package/src/data/load_geometry.test.ts +1 -1
  39. package/src/data/load_geometry.ts +3 -4
  40. package/src/data/program_configuration.ts +6 -11
  41. package/src/data/segment.ts +9 -6
  42. package/src/geo/edge_insets.test.ts +1 -1
  43. package/src/geo/edge_insets.ts +36 -26
  44. package/src/geo/lng_lat.test.ts +1 -1
  45. package/src/geo/lng_lat.ts +61 -44
  46. package/src/geo/lng_lat_bounds.test.ts +2 -2
  47. package/src/geo/lng_lat_bounds.ts +88 -68
  48. package/src/geo/mercator_coordinate.test.ts +2 -2
  49. package/src/geo/mercator_coordinate.ts +34 -27
  50. package/src/geo/transform.test.ts +3 -3
  51. package/src/geo/transform.ts +58 -79
  52. package/src/gl/color_mode.ts +1 -3
  53. package/src/gl/context.ts +12 -11
  54. package/src/gl/cull_face_mode.ts +1 -3
  55. package/src/gl/depth_mode.ts +1 -3
  56. package/src/gl/framebuffer.ts +5 -4
  57. package/src/gl/index_buffer.ts +5 -4
  58. package/src/gl/render_pool.test.ts +2 -2
  59. package/src/gl/render_pool.ts +5 -5
  60. package/src/gl/state.test.ts +1 -1
  61. package/src/gl/stencil_mode.ts +1 -3
  62. package/src/gl/value.ts +1 -1
  63. package/src/gl/vertex_buffer.test.ts +2 -2
  64. package/src/gl/vertex_buffer.ts +8 -14
  65. package/src/index.test.ts +2 -2
  66. package/src/index.ts +121 -113
  67. package/src/render/draw_background.ts +7 -9
  68. package/src/render/draw_circle.ts +13 -15
  69. package/src/render/draw_collision_debug.ts +11 -13
  70. package/src/render/draw_custom.ts +6 -8
  71. package/src/render/draw_debug.test.ts +4 -4
  72. package/src/render/draw_debug.ts +8 -10
  73. package/src/render/draw_fill.test.ts +13 -13
  74. package/src/render/draw_fill.ts +9 -11
  75. package/src/render/draw_fill_extrusion.ts +10 -12
  76. package/src/render/draw_heatmap.ts +12 -14
  77. package/src/render/draw_hillshade.ts +10 -12
  78. package/src/render/draw_line.ts +9 -9
  79. package/src/render/draw_raster.ts +9 -11
  80. package/src/render/draw_symbol.test.ts +16 -16
  81. package/src/render/draw_symbol.ts +15 -16
  82. package/src/render/draw_terrain.ts +11 -11
  83. package/src/render/glyph_atlas.ts +10 -1
  84. package/src/render/glyph_manager.test.ts +3 -3
  85. package/src/render/glyph_manager.ts +7 -7
  86. package/src/render/image_atlas.ts +6 -3
  87. package/src/render/image_manager.ts +3 -5
  88. package/src/render/line_atlas.test.ts +1 -1
  89. package/src/render/line_atlas.ts +19 -14
  90. package/src/render/painter.ts +85 -65
  91. package/src/render/program/background_program.ts +2 -2
  92. package/src/render/program/circle_program.ts +5 -5
  93. package/src/render/program/clipping_mask_program.ts +1 -1
  94. package/src/render/program/collision_program.ts +4 -4
  95. package/src/render/program/debug_program.ts +1 -1
  96. package/src/render/program/fill_extrusion_program.ts +3 -3
  97. package/src/render/program/fill_program.ts +3 -3
  98. package/src/render/program/heatmap_program.ts +5 -5
  99. package/src/render/program/hillshade_program.ts +7 -7
  100. package/src/render/program/line_program.ts +6 -6
  101. package/src/render/program/pattern.ts +3 -3
  102. package/src/render/program/raster_program.ts +2 -2
  103. package/src/render/program/symbol_program.ts +2 -2
  104. package/src/render/program/terrain_program.ts +1 -1
  105. package/src/render/program.ts +18 -16
  106. package/src/render/render_to_texture.test.ts +15 -15
  107. package/src/render/render_to_texture.ts +10 -10
  108. package/src/render/terrain.test.ts +38 -7
  109. package/src/render/terrain.ts +103 -67
  110. package/src/render/texture.ts +5 -4
  111. package/src/render/uniform_binding.test.ts +1 -1
  112. package/src/render/uniform_binding.ts +7 -1
  113. package/src/render/update_pattern_positions_in_program.ts +5 -5
  114. package/src/render/vertex_array_object.ts +9 -8
  115. package/src/shaders/encode_attribute.ts +0 -2
  116. package/src/shaders/shaders.ts +1 -3
  117. package/src/source/canvas_source.test.ts +6 -6
  118. package/src/source/canvas_source.ts +46 -60
  119. package/src/source/geojson_source.test.ts +5 -5
  120. package/src/source/geojson_source.ts +75 -59
  121. package/src/source/geojson_source_diff.ts +39 -2
  122. package/src/source/geojson_worker_source.test.ts +3 -3
  123. package/src/source/geojson_worker_source.ts +20 -26
  124. package/src/source/geojson_wrapper.test.ts +3 -3
  125. package/src/source/geojson_wrapper.ts +2 -4
  126. package/src/source/image_source.test.ts +9 -8
  127. package/src/source/image_source.ts +49 -35
  128. package/src/source/load_tilejson.ts +2 -2
  129. package/src/source/pixels_to_tile_units.ts +2 -3
  130. package/src/source/query_features.test.ts +3 -3
  131. package/src/source/query_features.ts +50 -19
  132. package/src/source/raster_dem_tile_source.test.ts +3 -3
  133. package/src/source/raster_dem_tile_source.ts +23 -10
  134. package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
  135. package/src/source/raster_dem_tile_worker_source.ts +3 -5
  136. package/src/source/raster_tile_source.test.ts +3 -3
  137. package/src/source/raster_tile_source.ts +38 -11
  138. package/src/source/rtl_text_plugin.ts +4 -1
  139. package/src/source/source.ts +67 -59
  140. package/src/source/source_cache.test.ts +7 -7
  141. package/src/source/source_cache.ts +17 -38
  142. package/src/source/source_state.ts +2 -5
  143. package/src/source/terrain_source_cache.test.ts +8 -8
  144. package/src/source/terrain_source_cache.ts +42 -27
  145. package/src/source/tile.test.ts +3 -3
  146. package/src/source/tile.ts +32 -38
  147. package/src/source/tile_bounds.ts +2 -4
  148. package/src/source/tile_cache.test.ts +2 -2
  149. package/src/source/tile_cache.ts +20 -30
  150. package/src/source/tile_id.ts +11 -2
  151. package/src/source/vector_tile_source.test.ts +3 -3
  152. package/src/source/vector_tile_source.ts +34 -24
  153. package/src/source/vector_tile_worker_source.test.ts +4 -4
  154. package/src/source/vector_tile_worker_source.ts +11 -23
  155. package/src/source/video_source.test.ts +5 -5
  156. package/src/source/video_source.ts +21 -28
  157. package/src/source/worker.ts +6 -8
  158. package/src/source/worker_source.ts +6 -8
  159. package/src/source/worker_tile.test.ts +5 -5
  160. package/src/source/worker_tile.ts +13 -16
  161. package/src/style/create_style_layer.ts +31 -26
  162. package/src/style/evaluation_parameters.ts +5 -4
  163. package/src/style/format_section_override.test.ts +2 -2
  164. package/src/style/format_section_override.ts +1 -1
  165. package/src/style/light.test.ts +2 -2
  166. package/src/style/light.ts +3 -5
  167. package/src/style/load_glyph_range.test.ts +1 -1
  168. package/src/style/load_glyph_range.ts +3 -3
  169. package/src/style/load_sprite.test.ts +1 -1
  170. package/src/style/load_sprite.ts +3 -3
  171. package/src/style/parse_glyph_pbf.ts +1 -1
  172. package/src/style/pauseable_placement.ts +7 -9
  173. package/src/style/properties.ts +4 -53
  174. package/src/style/query_utils.ts +3 -3
  175. package/src/style/style.test.ts +22 -19
  176. package/src/style/style.ts +118 -84
  177. package/src/style/style_glyph.ts +6 -0
  178. package/src/style/style_image.ts +39 -33
  179. package/src/style/style_layer/background_style_layer.ts +2 -4
  180. package/src/style/style_layer/circle_style_layer.ts +7 -6
  181. package/src/style/style_layer/custom_style_layer.ts +23 -48
  182. package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
  183. package/src/style/style_layer/fill_style_layer.ts +5 -7
  184. package/src/style/style_layer/heatmap_style_layer.ts +8 -7
  185. package/src/style/style_layer/hillshade_style_layer.ts +2 -4
  186. package/src/style/style_layer/line_style_layer.ts +6 -8
  187. package/src/style/style_layer/overlap_mode.test.ts +3 -3
  188. package/src/style/style_layer/overlap_mode.ts +3 -0
  189. package/src/style/style_layer/raster_style_layer.ts +2 -4
  190. package/src/style/style_layer/symbol_style_layer.ts +6 -8
  191. package/src/style/style_layer/typed_style_layer.ts +7 -7
  192. package/src/style/style_layer.test.ts +5 -5
  193. package/src/style/style_layer.ts +7 -6
  194. package/src/style/style_layer_index.test.ts +1 -1
  195. package/src/style/style_layer_index.ts +3 -5
  196. package/src/style/zoom_history.ts +1 -3
  197. package/src/symbol/anchor.test.ts +1 -1
  198. package/src/symbol/anchor.ts +1 -3
  199. package/src/symbol/check_max_angle.test.ts +8 -2
  200. package/src/symbol/check_max_angle.ts +10 -13
  201. package/src/symbol/clip_line.test.ts +1 -1
  202. package/src/symbol/clip_line.ts +6 -9
  203. package/src/symbol/collision_feature.test.ts +2 -2
  204. package/src/symbol/collision_feature.ts +7 -12
  205. package/src/symbol/collision_index.test.ts +2 -2
  206. package/src/symbol/collision_index.ts +5 -11
  207. package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
  208. package/src/symbol/cross_tile_symbol_index.ts +5 -7
  209. package/src/symbol/get_anchors.ts +2 -2
  210. package/src/symbol/grid_index.test.ts +1 -1
  211. package/src/symbol/grid_index.ts +4 -5
  212. package/src/symbol/merge_lines.test.ts +1 -1
  213. package/src/symbol/merge_lines.ts +1 -1
  214. package/src/symbol/opacity_state.ts +1 -3
  215. package/src/symbol/path_interpolator.test.ts +1 -1
  216. package/src/symbol/path_interpolator.ts +1 -3
  217. package/src/symbol/placement.ts +9 -9
  218. package/src/symbol/projection.ts +61 -34
  219. package/src/symbol/quads.ts +7 -11
  220. package/src/symbol/shaping.ts +1 -1
  221. package/src/symbol/symbol_layout.ts +9 -12
  222. package/src/symbol/symbol_size.ts +1 -1
  223. package/src/symbol/symbol_style_layer.test.ts +4 -4
  224. package/src/symbol/transform_text.ts +2 -2
  225. package/src/types/callback.ts +14 -14
  226. package/src/types/cancelable.ts +3 -0
  227. package/src/types/transferable.ts +3 -0
  228. package/src/ui/anchor.ts +4 -0
  229. package/src/ui/camera.test.ts +6 -6
  230. package/src/ui/camera.ts +392 -361
  231. package/src/ui/control/attribution_control.test.ts +1 -1
  232. package/src/ui/control/attribution_control.ts +34 -30
  233. package/src/ui/control/control.ts +14 -20
  234. package/src/ui/control/fullscreen_control.test.ts +1 -1
  235. package/src/ui/control/fullscreen_control.ts +21 -26
  236. package/src/ui/control/geolocate_control.test.ts +5 -5
  237. package/src/ui/control/geolocate_control.ts +181 -194
  238. package/src/ui/control/logo_control.ts +20 -16
  239. package/src/ui/control/navigation_control.test.ts +1 -1
  240. package/src/ui/control/navigation_control.ts +46 -42
  241. package/src/ui/control/scale_control.test.ts +1 -1
  242. package/src/ui/control/scale_control.ts +30 -21
  243. package/src/ui/control/terrain_control.test.ts +1 -1
  244. package/src/ui/control/terrain_control.ts +14 -18
  245. package/src/ui/default_locale.ts +1 -3
  246. package/src/ui/events.ts +570 -1281
  247. package/src/ui/handler/box_zoom.test.ts +2 -2
  248. package/src/ui/handler/box_zoom.ts +16 -11
  249. package/src/ui/handler/click_zoom.ts +11 -3
  250. package/src/ui/handler/cooperative_gestures.test.ts +3 -3
  251. package/src/ui/handler/dblclick_zoom.test.ts +1 -1
  252. package/src/ui/handler/drag_handler.ts +30 -22
  253. package/src/ui/handler/drag_move_state_manager.ts +1 -1
  254. package/src/ui/handler/drag_pan.test.ts +2 -2
  255. package/src/ui/handler/drag_rotate.test.ts +3 -3
  256. package/src/ui/handler/keyboard.test.ts +2 -2
  257. package/src/ui/handler/keyboard.ts +22 -13
  258. package/src/ui/handler/map_event.test.ts +2 -2
  259. package/src/ui/handler/map_event.ts +1 -1
  260. package/src/ui/handler/mouse.ts +1 -1
  261. package/src/ui/handler/mouse_rotate.test.ts +3 -3
  262. package/src/ui/handler/scroll_zoom.test.ts +3 -3
  263. package/src/ui/handler/scroll_zoom.ts +45 -52
  264. package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
  265. package/src/ui/handler/shim/drag_pan.ts +34 -14
  266. package/src/ui/handler/shim/drag_rotate.ts +20 -12
  267. package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
  268. package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
  269. package/src/ui/handler/tap_drag_zoom.ts +18 -10
  270. package/src/ui/handler/tap_recognizer.ts +1 -1
  271. package/src/ui/handler/tap_zoom.ts +4 -3
  272. package/src/ui/handler/touch_pan.ts +3 -2
  273. package/src/ui/handler/transform-provider.ts +4 -6
  274. package/src/ui/handler/two_fingers_touch.test.ts +3 -3
  275. package/src/ui/handler/two_fingers_touch.ts +64 -47
  276. package/src/ui/handler_inertia.ts +4 -4
  277. package/src/ui/handler_manager.ts +86 -52
  278. package/src/ui/hash.test.ts +1 -1
  279. package/src/ui/hash.ts +21 -28
  280. package/src/ui/map/isMoving.test.ts +3 -3
  281. package/src/ui/map/isRotating.test.ts +3 -3
  282. package/src/ui/map/isZooming.test.ts +3 -3
  283. package/src/ui/map.test.ts +97 -8
  284. package/src/ui/map.ts +856 -702
  285. package/src/ui/map_events.test.ts +1 -1
  286. package/src/ui/marker.test.ts +35 -15
  287. package/src/ui/marker.ts +220 -141
  288. package/src/ui/popup.test.ts +2 -2
  289. package/src/ui/popup.ts +179 -147
  290. package/src/util/actor.test.ts +7 -7
  291. package/src/util/actor.ts +25 -22
  292. package/src/util/ajax.ts +37 -17
  293. package/src/util/browser.test.ts +1 -1
  294. package/src/util/browser.ts +2 -6
  295. package/src/util/classify_rings.test.ts +1 -1
  296. package/src/util/classify_rings.ts +1 -1
  297. package/src/util/color_ramp.ts +0 -2
  298. package/src/util/config.ts +6 -3
  299. package/src/util/debug.ts +0 -2
  300. package/src/util/dictionary_coder.ts +1 -4
  301. package/src/util/dispatcher.test.ts +3 -3
  302. package/src/util/dispatcher.ts +4 -9
  303. package/src/util/dom.ts +1 -1
  304. package/src/util/evented.ts +23 -18
  305. package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
  306. package/src/util/find_pole_of_inaccessibility.ts +4 -5
  307. package/src/util/global_worker_pool.ts +2 -3
  308. package/src/util/image.ts +10 -4
  309. package/src/util/image_request.test.ts +3 -3
  310. package/src/util/image_request.ts +15 -14
  311. package/src/util/is_char_in_unicode_block.ts +1 -3
  312. package/src/util/offscreen_canvas_supported.ts +1 -1
  313. package/src/util/performance.ts +1 -2
  314. package/src/util/request_manager.ts +4 -0
  315. package/src/util/resolve_tokens.test.ts +1 -1
  316. package/src/util/resolve_tokens.ts +3 -6
  317. package/src/util/script_detection.ts +1 -4
  318. package/src/util/smart_wrap.ts +3 -5
  319. package/src/util/struct_array.ts +18 -14
  320. package/src/util/style.ts +2 -2
  321. package/src/util/task_queue.test.ts +1 -1
  322. package/src/util/task_queue.ts +1 -3
  323. package/src/util/test/mock_webgl.ts +6 -0
  324. package/src/util/test/util.ts +2 -2
  325. package/src/util/throttle.test.ts +1 -1
  326. package/src/util/throttle.ts +1 -2
  327. package/src/util/throttled_invoker.ts +1 -5
  328. package/src/util/transferable_grid_index.test.ts +1 -1
  329. package/src/util/transferable_grid_index.ts +1 -3
  330. package/src/util/util.test.ts +1 -14
  331. package/src/util/util.ts +44 -107
  332. package/src/util/vectortile_to_geojson.ts +13 -3
  333. package/src/util/verticalize_punctuation.ts +1 -1
  334. package/src/util/web_worker.ts +2 -2
  335. package/src/util/web_worker_transfer.ts +11 -8
  336. package/src/util/webp_supported.ts +2 -4
  337. package/src/util/worker_pool.test.ts +1 -1
  338. package/src/util/worker_pool.ts +4 -5
@@ -7,15 +7,24 @@ import {clamp} from '../util/util';
7
7
  * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
8
8
  * on top of the map and having the vanishing point shift as UI elements resize.
9
9
  *
10
- * @param {number} [top=0]
11
- * @param {number} [bottom=0]
12
- * @param {number} [left=0]
13
- * @param {number} [right=0]
10
+ * @group Geography and Geometry
14
11
  */
15
- class EdgeInsets {
12
+ export class EdgeInsets {
13
+ /**
14
+ * @defaultValue 0
15
+ */
16
16
  top: number;
17
+ /**
18
+ * @defaultValue 0
19
+ */
17
20
  bottom: number;
21
+ /**
22
+ * @defaultValue 0
23
+ */
18
24
  left: number;
25
+ /**
26
+ * @defaultValue 0
27
+ */
19
28
  right: number;
20
29
 
21
30
  constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) {
@@ -36,11 +45,10 @@ class EdgeInsets {
36
45
  /**
37
46
  * Interpolates the inset in-place.
38
47
  * This maintains the current inset value for any inset not present in `target`.
39
- * @param {PaddingOptions | EdgeInsets} start interpolation start
40
- * @param {PaddingOptions} target interpolation target
41
- * @param {number} t interpolation step/weight
42
- * @returns {EdgeInsets} the insets
43
- * @memberof EdgeInsets
48
+ * @param start - interpolation start
49
+ * @param target - interpolation target
50
+ * @param t - interpolation step/weight
51
+ * @returns the insets
44
52
  */
45
53
  interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets {
46
54
  if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t);
@@ -55,10 +63,9 @@ class EdgeInsets {
55
63
  * Utility method that computes the new apprent center or vanishing point after applying insets.
56
64
  * This is in pixels and with the top left being (0.0) and +y being downwards.
57
65
  *
58
- * @param {number} width the width
59
- * @param {number} height the height
60
- * @returns {Point} the point
61
- * @memberof EdgeInsets
66
+ * @param width - the width
67
+ * @param height - the height
68
+ * @returns the point
62
69
  */
63
70
  getCenter(width: number, height: number): Point {
64
71
  // Clamp insets so they never overflow width/height and always calculate a valid center
@@ -83,8 +90,7 @@ class EdgeInsets {
83
90
  * Returns the current state as json, useful when you want to have a
84
91
  * read-only representation of the inset.
85
92
  *
86
- * @returns {PaddingOptions} state as json
87
- * @memberof EdgeInsets
93
+ * @returns state as json
88
94
  */
89
95
  toJSON(): PaddingOptions {
90
96
  return {
@@ -100,37 +106,41 @@ class EdgeInsets {
100
106
  * 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
101
107
  * non-negative integers.
102
108
  *
109
+ * @group Geography and Geometry
110
+ *
103
111
  * @example
104
- * var bbox = [[-79, 43], [-73, 45]];
112
+ * ```ts
113
+ * let bbox = [[-79, 43], [-73, 45]];
105
114
  * map.fitBounds(bbox, {
106
115
  * padding: {top: 10, bottom:25, left: 15, right: 5}
107
116
  * });
117
+ * ```
108
118
  *
109
119
  * @example
110
- * var bbox = [[-79, 43], [-73, 45]];
120
+ * ```ts
121
+ * let bbox = [[-79, 43], [-73, 45]];
111
122
  * map.fitBounds(bbox, {
112
123
  * padding: 20
113
124
  * });
114
- * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js-docs/example/zoomto-linestring/)
115
- * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js-docs/example/fitbounds/)
125
+ * ```
126
+ * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)
127
+ * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)
116
128
  */
117
129
  export type PaddingOptions = {
118
130
  /**
119
- * @property {number} top Padding in pixels from the top of the map canvas.
131
+ * Padding in pixels from the top of the map canvas.
120
132
  */
121
133
  top: number;
122
134
  /**
123
- * @property {number} bottom Padding in pixels from the bottom of the map canvas.
135
+ * Padding in pixels from the bottom of the map canvas.
124
136
  */
125
137
  bottom: number;
126
138
  /**
127
- * @property {number} left Padding in pixels from the left of the map canvas.
139
+ * Padding in pixels from the left of the map canvas.
128
140
  */
129
141
  right: number;
130
142
  /**
131
- * @property {number} right Padding in pixels from the right of the map canvas.
143
+ * Padding in pixels from the right of the map canvas.
132
144
  */
133
145
  left: number;
134
146
  };
135
-
136
- export default EdgeInsets;
@@ -1,4 +1,4 @@
1
- import LngLat from '../geo/lng_lat';
1
+ import {LngLat} from '../geo/lng_lat';
2
2
 
3
3
  describe('LngLat', () => {
4
4
  test('#constructor', () => {
@@ -7,6 +7,27 @@ import {wrap} from '../util/util';
7
7
  */
8
8
  export const earthRadius = 6371008.8;
9
9
 
10
+ /**
11
+ * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
12
+ * or an object with `lng` and `lat` or `lon` and `lat` properties.
13
+ *
14
+ * @group Geography and Geometry
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * let v1 = new maplibregl.LngLat(-122.420679, 37.772537);
19
+ * let v2 = [-122.420679, 37.772537];
20
+ * let v3 = {lon: -122.420679, lat: 37.772537};
21
+ * ```
22
+ */
23
+ export type LngLatLike = LngLat | {
24
+ lng: number;
25
+ lat: number;
26
+ } | {
27
+ lon: number;
28
+ lat: number;
29
+ } | [number, number];
30
+
10
31
  /**
11
32
  * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
12
33
  * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
@@ -18,19 +39,25 @@ export const earthRadius = 6371008.8;
18
39
  * can also accept an `Array` of two numbers and will perform an implicit conversion.
19
40
  * This flexible type is documented as {@link LngLatLike}.
20
41
  *
21
- * @param {number} lng Longitude, measured in degrees.
22
- * @param {number} lat Latitude, measured in degrees.
42
+ * @group Geography and Geometry
43
+ *
23
44
  * @example
24
- * var ll = new maplibregl.LngLat(-123.9749, 40.7736);
45
+ * ```ts
46
+ * let ll = new maplibregl.LngLat(-123.9749, 40.7736);
25
47
  * ll.lng; // = -123.9749
26
- * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/mouse-position/)
27
- * @see [Display a popup](https://maplibre.org/maplibre-gl-js-docs/example/popup/)
28
- * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js-docs/example/timeline-animation/)
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/)
29
52
  */
30
- class LngLat {
53
+ export class LngLat {
31
54
  lng: number;
32
55
  lat: number;
33
56
 
57
+ /**
58
+ * @param lng - Longitude, measured in degrees.
59
+ * @param lat - Latitude, measured in degrees.
60
+ */
34
61
  constructor(lng: number, lat: number) {
35
62
  if (isNaN(lng) || isNaN(lat)) {
36
63
  throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
@@ -45,11 +72,13 @@ class LngLat {
45
72
  /**
46
73
  * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
47
74
  *
48
- * @returns {LngLat} The wrapped `LngLat` object.
75
+ * @returns The wrapped `LngLat` object.
49
76
  * @example
50
- * var ll = new maplibregl.LngLat(286.0251, 40.7736);
51
- * var wrapped = ll.wrap();
77
+ * ```ts
78
+ * let ll = new maplibregl.LngLat(286.0251, 40.7736);
79
+ * let wrapped = ll.wrap();
52
80
  * wrapped.lng; // = -73.9749
81
+ * ```
53
82
  */
54
83
  wrap() {
55
84
  return new LngLat(wrap(this.lng, -180, 180), this.lat);
@@ -58,10 +87,12 @@ class LngLat {
58
87
  /**
59
88
  * Returns the coordinates represented as an array of two numbers.
60
89
  *
61
- * @returns {[number,number]} The coordinates represented as an array of longitude and latitude.
90
+ * @returns The coordinates represented as an array of longitude and latitude.
62
91
  * @example
63
- * var ll = new maplibregl.LngLat(-73.9749, 40.7736);
92
+ * ```ts
93
+ * let ll = new maplibregl.LngLat(-73.9749, 40.7736);
64
94
  * ll.toArray(); // = [-73.9749, 40.7736]
95
+ * ```
65
96
  */
66
97
  toArray(): [number, number] {
67
98
  return [this.lng, this.lat];
@@ -70,12 +101,14 @@ class LngLat {
70
101
  /**
71
102
  * Returns the coordinates represent as a string.
72
103
  *
73
- * @returns {string} The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
104
+ * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
74
105
  * @example
75
- * var ll = new maplibregl.LngLat(-73.9749, 40.7736);
106
+ * ```ts
107
+ * let ll = new maplibregl.LngLat(-73.9749, 40.7736);
76
108
  * ll.toString(); // = "LngLat(-73.9749, 40.7736)"
109
+ * ```
77
110
  */
78
- toString() {
111
+ toString(): string {
79
112
  return `LngLat(${this.lng}, ${this.lat})`;
80
113
  }
81
114
 
@@ -83,14 +116,16 @@ class LngLat {
83
116
  * Returns the approximate distance between a pair of coordinates in meters
84
117
  * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
85
118
  *
86
- * @param {LngLat} lngLat coordinates to compute the distance to
87
- * @returns {number} Distance in meters between the two coordinates.
119
+ * @param lngLat - coordinates to compute the distance to
120
+ * @returns Distance in meters between the two coordinates.
88
121
  * @example
89
- * var new_york = new maplibregl.LngLat(-74.0060, 40.7128);
90
- * var los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);
122
+ * ```ts
123
+ * let new_york = new maplibregl.LngLat(-74.0060, 40.7128);
124
+ * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);
91
125
  * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
126
+ * ```
92
127
  */
93
- distanceTo(lngLat: LngLat) {
128
+ distanceTo(lngLat: LngLat): number {
94
129
  const rad = Math.PI / 180;
95
130
  const lat1 = this.lat * rad;
96
131
  const lat2 = lngLat.lat * rad;
@@ -106,12 +141,14 @@ class LngLat {
106
141
  *
107
142
  * If a `LngLat` object is passed in, the function returns it unchanged.
108
143
  *
109
- * @param {LngLatLike} input An array of two numbers or object to convert, or a `LngLat` object to return.
110
- * @returns {LngLat} A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
144
+ * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
145
+ * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
111
146
  * @example
112
- * var arr = [-73.9749, 40.7736];
113
- * var ll = maplibregl.LngLat.convert(arr);
147
+ * ```ts
148
+ * let arr = [-73.9749, 40.7736];
149
+ * let ll = maplibregl.LngLat.convert(arr);
114
150
  * ll; // = LngLat {lng: -73.9749, lat: 40.7736}
151
+ * ```
115
152
  */
116
153
  static convert(input: LngLatLike): LngLat {
117
154
  if (input instanceof LngLat) {
@@ -130,23 +167,3 @@ class LngLat {
130
167
  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>]');
131
168
  }
132
169
  }
133
-
134
- /**
135
- * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
136
- * or an object with `lng` and `lat` or `lon` and `lat` properties.
137
- *
138
- * @typedef {LngLat | {lng: number, lat: number} | {lon: number, lat: number} | [number, number]} LngLatLike
139
- * @example
140
- * var v1 = new maplibregl.LngLat(-122.420679, 37.772537);
141
- * var v2 = [-122.420679, 37.772537];
142
- * var v3 = {lon: -122.420679, lat: 37.772537};
143
- */
144
- export type LngLatLike = LngLat | {
145
- lng: number;
146
- lat: number;
147
- } | {
148
- lon: number;
149
- lat: number;
150
- } | [number, number];
151
-
152
- export default LngLat;
@@ -1,5 +1,5 @@
1
- import LngLat from './lng_lat';
2
- import LngLatBounds from './lng_lat_bounds';
1
+ import {LngLat} from './lng_lat';
2
+ import {LngLatBounds} from './lng_lat_bounds';
3
3
 
4
4
  describe('LngLatBounds', () => {
5
5
  test('#constructor', () => {
@@ -1,6 +1,24 @@
1
- import LngLat from './lng_lat';
1
+ import {LngLat} from './lng_lat';
2
2
  import type {LngLatLike} from './lng_lat';
3
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 maplibregl.LngLatBounds(
13
+ * new maplibregl.LngLat(-73.9876, 40.7661),
14
+ * new maplibregl.LngLat(-73.9397, 40.8002)
15
+ * );
16
+ * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
17
+ * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
18
+ * ```
19
+ */
20
+ export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];
21
+
4
22
  /**
5
23
  * A `LngLatBounds` object represents a geographical bounding box,
6
24
  * defined by its southwest and northeast points in longitude and latitude.
@@ -11,30 +29,38 @@ import type {LngLatLike} from './lng_lat';
11
29
  * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.
12
30
  * This flexible type is documented as {@link LngLatBoundsLike}.
13
31
  *
14
- * @param {LngLatLike} [sw] The southwest corner of the bounding box.
15
- * @param {LngLatLike} [ne] The northeast corner of the bounding box.
32
+ * @group Geography and Geometry
33
+ *
16
34
  * @example
17
- * var sw = new maplibregl.LngLat(-73.9876, 40.7661);
18
- * var ne = new maplibregl.LngLat(-73.9397, 40.8002);
19
- * var llb = new maplibregl.LngLatBounds(sw, ne);
35
+ * ```ts
36
+ * let sw = new maplibregl.LngLat(-73.9876, 40.7661);
37
+ * let ne = new maplibregl.LngLat(-73.9397, 40.8002);
38
+ * let llb = new maplibregl.LngLatBounds(sw, ne);
39
+ * ```
20
40
  */
21
- class LngLatBounds {
41
+ export class LngLatBounds {
22
42
  _ne: LngLat;
23
43
  _sw: LngLat;
24
44
 
25
45
  /**
26
- * @param {LngLatLike} [sw] The southwest corner of the bounding box.
46
+ * @param sw - The southwest corner of the bounding box.
27
47
  * OR array of 4 numbers in the order of west, south, east, north
28
48
  * OR array of 2 LngLatLike: [sw,ne]
29
- * @param {LngLatLike} [ne] The northeast corner of the bounding box.
49
+ * @param ne - The northeast corner of the bounding box.
30
50
  * @example
31
- * var sw = new maplibregl.LngLat(-73.9876, 40.7661);
32
- * var ne = new maplibregl.LngLat(-73.9397, 40.8002);
33
- * var llb = new maplibregl.LngLatBounds(sw, ne);
51
+ * ```ts
52
+ * let sw = new maplibregl.LngLat(-73.9876, 40.7661);
53
+ * let ne = new maplibregl.LngLat(-73.9397, 40.8002);
54
+ * let llb = new maplibregl.LngLatBounds(sw, ne);
55
+ * ```
34
56
  * OR
35
- * var llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);
57
+ * ```ts
58
+ * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);
59
+ * ```
36
60
  * OR
37
- * var llb = new maplibregl.LngLatBounds([sw, ne]);
61
+ * ```ts
62
+ * let llb = new maplibregl.LngLatBounds([sw, ne]);
63
+ * ```
38
64
  */
39
65
  constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike) {
40
66
  if (!sw) {
@@ -54,10 +80,10 @@ class LngLatBounds {
54
80
  /**
55
81
  * Set the northeast corner of the bounding box
56
82
  *
57
- * @param {LngLatLike} ne a {@link LngLatLike} object describing the northeast corner of the bounding box.
58
- * @returns {LngLatBounds} `this`
83
+ * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.
84
+ * @returns `this`
59
85
  */
60
- setNorthEast(ne: LngLatLike) {
86
+ setNorthEast(ne: LngLatLike): this {
61
87
  this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);
62
88
  return this;
63
89
  }
@@ -65,10 +91,10 @@ class LngLatBounds {
65
91
  /**
66
92
  * Set the southwest corner of the bounding box
67
93
  *
68
- * @param {LngLatLike} sw a {@link LngLatLike} object describing the southwest corner of the bounding box.
69
- * @returns {LngLatBounds} `this`
94
+ * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.
95
+ * @returns `this`
70
96
  */
71
- setSouthWest(sw: LngLatLike) {
97
+ setSouthWest(sw: LngLatLike): this {
72
98
  this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);
73
99
  return this;
74
100
  }
@@ -76,10 +102,10 @@ class LngLatBounds {
76
102
  /**
77
103
  * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.
78
104
  *
79
- * @param {LngLatLike|LngLatBoundsLike} obj object to extend to
80
- * @returns {LngLatBounds} `this`
105
+ * @param obj - object to extend to
106
+ * @returns `this`
81
107
  */
82
- extend(obj: LngLatLike | LngLatBoundsLike) {
108
+ extend(obj: LngLatLike | LngLatBoundsLike): this {
83
109
  const sw = this._sw,
84
110
  ne = this._ne;
85
111
  let sw2, ne2;
@@ -128,10 +154,12 @@ class LngLatBounds {
128
154
  /**
129
155
  * Returns the geographical coordinate equidistant from the bounding box's corners.
130
156
  *
131
- * @returns {LngLat} The bounding box's center.
157
+ * @returns The bounding box's center.
132
158
  * @example
133
- * var llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
159
+ * ```ts
160
+ * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
134
161
  * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
162
+ * ```
135
163
  */
136
164
  getCenter(): LngLat {
137
165
  return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
@@ -140,67 +168,69 @@ class LngLatBounds {
140
168
  /**
141
169
  * Returns the southwest corner of the bounding box.
142
170
  *
143
- * @returns {LngLat} The southwest corner of the bounding box.
171
+ * @returns The southwest corner of the bounding box.
144
172
  */
145
173
  getSouthWest(): LngLat { return this._sw; }
146
174
 
147
175
  /**
148
176
  * Returns the northeast corner of the bounding box.
149
177
  *
150
- * @returns {LngLat} The northeast corner of the bounding box.
178
+ * @returns The northeast corner of the bounding box.
151
179
  */
152
180
  getNorthEast(): LngLat { return this._ne; }
153
181
 
154
182
  /**
155
183
  * Returns the northwest corner of the bounding box.
156
184
  *
157
- * @returns {LngLat} The northwest corner of the bounding box.
185
+ * @returns The northwest corner of the bounding box.
158
186
  */
159
187
  getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); }
160
188
 
161
189
  /**
162
190
  * Returns the southeast corner of the bounding box.
163
191
  *
164
- * @returns {LngLat} The southeast corner of the bounding box.
192
+ * @returns The southeast corner of the bounding box.
165
193
  */
166
194
  getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); }
167
195
 
168
196
  /**
169
197
  * Returns the west edge of the bounding box.
170
198
  *
171
- * @returns {number} The west edge of the bounding box.
199
+ * @returns The west edge of the bounding box.
172
200
  */
173
201
  getWest(): number { return this._sw.lng; }
174
202
 
175
203
  /**
176
204
  * Returns the south edge of the bounding box.
177
205
  *
178
- * @returns {number} The south edge of the bounding box.
206
+ * @returns The south edge of the bounding box.
179
207
  */
180
208
  getSouth(): number { return this._sw.lat; }
181
209
 
182
210
  /**
183
211
  * Returns the east edge of the bounding box.
184
212
  *
185
- * @returns {number} The east edge of the bounding box.
213
+ * @returns The east edge of the bounding box.
186
214
  */
187
215
  getEast(): number { return this._ne.lng; }
188
216
 
189
217
  /**
190
218
  * Returns the north edge of the bounding box.
191
219
  *
192
- * @returns {number} The north edge of the bounding box.
220
+ * @returns The north edge of the bounding box.
193
221
  */
194
222
  getNorth(): number { return this._ne.lat; }
195
223
 
196
224
  /**
197
225
  * Returns the bounding box represented as an array.
198
226
  *
199
- * @returns {Array<Array<number>>} The bounding box represented as an array, consisting of the
227
+ * @returns The bounding box represented as an array, consisting of the
200
228
  * southwest and northeast coordinates of the bounding represented as arrays of numbers.
201
229
  * @example
202
- * var llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
230
+ * ```ts
231
+ * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
203
232
  * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
233
+ * ```
204
234
  */
205
235
  toArray() {
206
236
  return [this._sw.toArray(), this._ne.toArray()];
@@ -209,11 +239,13 @@ class LngLatBounds {
209
239
  /**
210
240
  * Return the bounding box represented as a string.
211
241
  *
212
- * @returns {string} The bounding box represents as a string of the format
242
+ * @returns The bounding box represents as a string of the format
213
243
  * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
214
244
  * @example
215
- * var llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
245
+ * ```ts
246
+ * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
216
247
  * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
248
+ * ```
217
249
  */
218
250
  toString() {
219
251
  return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
@@ -222,7 +254,7 @@ class LngLatBounds {
222
254
  /**
223
255
  * Check if the bounding box is an empty/`null`-type box.
224
256
  *
225
- * @returns {boolean} True if bounds have been defined, otherwise false.
257
+ * @returns True if bounds have been defined, otherwise false.
226
258
  */
227
259
  isEmpty() {
228
260
  return !(this._sw && this._ne);
@@ -231,17 +263,19 @@ class LngLatBounds {
231
263
  /**
232
264
  * Check if the point is within the bounding box.
233
265
  *
234
- * @param {LngLatLike} lnglat geographic point to check against.
235
- * @returns {boolean} True if the point is within the bounding box.
266
+ * @param lnglat - geographic point to check against.
267
+ * @returns `true` if the point is within the bounding box.
236
268
  * @example
237
- * var llb = new maplibregl.LngLatBounds(
269
+ * ```ts
270
+ * let llb = new maplibregl.LngLatBounds(
238
271
  * new maplibregl.LngLat(-73.9876, 40.7661),
239
272
  * new maplibregl.LngLat(-73.9397, 40.8002)
240
273
  * );
241
274
  *
242
- * var ll = new maplibregl.LngLat(-73.9567, 40.7789);
275
+ * let ll = new maplibregl.LngLat(-73.9567, 40.7789);
243
276
  *
244
277
  * console.log(llb.contains(ll)); // = true
278
+ * ```
245
279
  */
246
280
  contains(lnglat: LngLatLike) {
247
281
  const {lng, lat} = LngLat.convert(lnglat);
@@ -262,12 +296,13 @@ class LngLatBounds {
262
296
  *
263
297
  * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.
264
298
  *
265
- * @param {LngLatBoundsLike} input An array of two coordinates to convert, or a `LngLatBounds` object to return.
266
- * @returns {LngLatBounds} A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
299
+ * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.
300
+ * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
267
301
  * @example
268
- * var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
269
- * var llb = maplibregl.LngLatBounds.convert(arr);
270
- * llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
302
+ * ```ts
303
+ * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
304
+ * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
305
+ * ```
271
306
  */
272
307
  static convert(input: LngLatBoundsLike | null): LngLatBounds {
273
308
  if (input instanceof LngLatBounds) return input;
@@ -278,12 +313,14 @@ class LngLatBounds {
278
313
  /**
279
314
  * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.
280
315
  *
281
- * @param center center coordinates of the new bounds.
282
- * @param {number} [radius=0] Distance in meters from the coordinates to extend the bounds.
283
- * @returns {LngLatBounds} A new `LngLatBounds` object representing the coordinates extended by the `radius`.
316
+ * @param center - center coordinates of the new bounds.
317
+ * @param radius - Distance in meters from the coordinates to extend the bounds.
318
+ * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.
284
319
  * @example
285
- * var center = new maplibregl.LngLat(-73.9749, 40.7736);
320
+ * ```ts
321
+ * let center = new maplibregl.LngLat(-73.9749, 40.7736);
286
322
  * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
323
+ * ```
287
324
  */
288
325
  static fromLngLat(center: LngLat, radius:number = 0): LngLatBounds {
289
326
  const earthCircumferenceInMetersAtEquator = 40075017;
@@ -294,20 +331,3 @@ class LngLatBounds {
294
331
  new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy));
295
332
  }
296
333
  }
297
-
298
- /**
299
- * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,
300
- * or an array of numbers in [west, south, east, north] order.
301
- *
302
- * @typedef {LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]} LngLatBoundsLike
303
- * @example
304
- * var v1 = new maplibregl.LngLatBounds(
305
- * new maplibregl.LngLat(-73.9876, 40.7661),
306
- * new maplibregl.LngLat(-73.9397, 40.8002)
307
- * );
308
- * var v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
309
- * var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
310
- */
311
- export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];
312
-
313
- export default LngLatBounds;
@@ -1,5 +1,5 @@
1
- import LngLat from './lng_lat';
2
- import MercatorCoordinate, {mercatorScale} from './mercator_coordinate';
1
+ import {LngLat} from './lng_lat';
2
+ import {MercatorCoordinate, mercatorScale} from './mercator_coordinate';
3
3
 
4
4
  describe('LngLat', () => {
5
5
  test('#constructor', () => {