mapbox-gl 1.13.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 (460) hide show
  1. package/.flowconfig +61 -0
  2. package/CHANGELOG.md +2485 -0
  3. package/LICENSE.txt +84 -0
  4. package/README.md +34 -0
  5. package/build/banner.js +4 -0
  6. package/build/check-bundle-size.js +140 -0
  7. package/build/diff-tarball.js +18 -0
  8. package/build/generate-access-token-script.js +11 -0
  9. package/build/generate-flow-typed-style-spec.js +188 -0
  10. package/build/generate-release-list.js +21 -0
  11. package/build/generate-struct-arrays.js +243 -0
  12. package/build/generate-style-code.js +159 -0
  13. package/build/mapbox-gl.js.flow +3 -0
  14. package/build/print-release-url.js +6 -0
  15. package/build/rollup_plugin_minify_style_spec.js +24 -0
  16. package/build/rollup_plugins.js +80 -0
  17. package/build/run-node +3 -0
  18. package/build/run-tap +8 -0
  19. package/build/test/build-tape.js +19 -0
  20. package/dist/mapbox-gl-csp-worker.js +2 -0
  21. package/dist/mapbox-gl-csp-worker.js.map +1 -0
  22. package/dist/mapbox-gl-csp.js +2 -0
  23. package/dist/mapbox-gl-csp.js.map +1 -0
  24. package/dist/mapbox-gl-dev.js +65889 -0
  25. package/dist/mapbox-gl-dev.js.flow +3 -0
  26. package/dist/mapbox-gl-unminified.js +42889 -0
  27. package/dist/mapbox-gl-unminified.js.map +1 -0
  28. package/dist/mapbox-gl.css +1 -0
  29. package/dist/mapbox-gl.js +42 -0
  30. package/dist/mapbox-gl.js.flow +3 -0
  31. package/dist/mapbox-gl.js.map +1 -0
  32. package/dist/style-spec/index.es.js +15032 -0
  33. package/dist/style-spec/index.es.js.map +1 -0
  34. package/dist/style-spec/index.js +15058 -0
  35. package/dist/style-spec/index.js.map +1 -0
  36. package/flow-typed/gl.js +5 -0
  37. package/flow-typed/jsdom.js +18 -0
  38. package/flow-typed/mapbox-gl-supported.js +9 -0
  39. package/flow-typed/mapbox-unitbezier.js +14 -0
  40. package/flow-typed/offscreen-canvas.js +9 -0
  41. package/flow-typed/pbf.js +25 -0
  42. package/flow-typed/point-geometry.js +44 -0
  43. package/flow-typed/potpack.js +12 -0
  44. package/flow-typed/sinon.js +28 -0
  45. package/flow-typed/vector-tile.js +41 -0
  46. package/package.json +173 -0
  47. package/src/css/mapbox-gl.css +812 -0
  48. package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
  49. package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
  50. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
  51. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +5 -0
  52. package/src/css/svg/mapboxgl-ctrl-logo.svg +20 -0
  53. package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
  54. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
  55. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
  56. package/src/data/array_types.js +1135 -0
  57. package/src/data/bucket/circle_attributes.js +9 -0
  58. package/src/data/bucket/circle_bucket.js +201 -0
  59. package/src/data/bucket/fill_attributes.js +9 -0
  60. package/src/data/bucket/fill_bucket.js +229 -0
  61. package/src/data/bucket/fill_extrusion_attributes.js +10 -0
  62. package/src/data/bucket/fill_extrusion_bucket.js +283 -0
  63. package/src/data/bucket/heatmap_bucket.js +17 -0
  64. package/src/data/bucket/line_attributes.js +10 -0
  65. package/src/data/bucket/line_attributes_ext.js +10 -0
  66. package/src/data/bucket/line_bucket.js +594 -0
  67. package/src/data/bucket/pattern_attributes.js +12 -0
  68. package/src/data/bucket/pattern_bucket_features.js +60 -0
  69. package/src/data/bucket/symbol_attributes.js +117 -0
  70. package/src/data/bucket/symbol_bucket.js +937 -0
  71. package/src/data/bucket.js +123 -0
  72. package/src/data/dem_data.js +125 -0
  73. package/src/data/evaluation_feature.js +25 -0
  74. package/src/data/extent.js +18 -0
  75. package/src/data/feature_index.js +322 -0
  76. package/src/data/feature_position_map.js +131 -0
  77. package/src/data/index_array_type.js +16 -0
  78. package/src/data/load_geometry.js +46 -0
  79. package/src/data/pos_attributes.js +6 -0
  80. package/src/data/program_configuration.js +708 -0
  81. package/src/data/raster_bounds_attributes.js +7 -0
  82. package/src/data/segment.js +76 -0
  83. package/src/geo/edge_insets.js +102 -0
  84. package/src/geo/lng_lat.js +168 -0
  85. package/src/geo/lng_lat_bounds.js +276 -0
  86. package/src/geo/mercator_coordinate.js +150 -0
  87. package/src/geo/transform.js +834 -0
  88. package/src/gl/color_mode.js +34 -0
  89. package/src/gl/context.js +302 -0
  90. package/src/gl/cull_face_mode.js +26 -0
  91. package/src/gl/depth_mode.js +29 -0
  92. package/src/gl/framebuffer.js +44 -0
  93. package/src/gl/index_buffer.js +55 -0
  94. package/src/gl/stencil_mode.js +30 -0
  95. package/src/gl/types.js +84 -0
  96. package/src/gl/value.js +520 -0
  97. package/src/gl/vertex_buffer.js +119 -0
  98. package/src/index.js +230 -0
  99. package/src/render/draw_background.js +57 -0
  100. package/src/render/draw_circle.js +113 -0
  101. package/src/render/draw_collision_debug.js +172 -0
  102. package/src/render/draw_custom.js +49 -0
  103. package/src/render/draw_debug.js +127 -0
  104. package/src/render/draw_fill.js +124 -0
  105. package/src/render/draw_fill_extrusion.js +95 -0
  106. package/src/render/draw_heatmap.js +133 -0
  107. package/src/render/draw_hillshade.js +107 -0
  108. package/src/render/draw_line.js +125 -0
  109. package/src/render/draw_raster.js +125 -0
  110. package/src/render/draw_symbol.js +392 -0
  111. package/src/render/glyph_atlas.js +71 -0
  112. package/src/render/glyph_manager.js +182 -0
  113. package/src/render/image_atlas.js +149 -0
  114. package/src/render/image_manager.js +306 -0
  115. package/src/render/line_atlas.js +210 -0
  116. package/src/render/painter.js +654 -0
  117. package/src/render/program/background_program.js +103 -0
  118. package/src/render/program/circle_program.js +69 -0
  119. package/src/render/program/clipping_mask_program.js +20 -0
  120. package/src/render/program/collision_program.js +76 -0
  121. package/src/render/program/debug_program.js +35 -0
  122. package/src/render/program/fill_extrusion_program.js +122 -0
  123. package/src/render/program/fill_program.js +126 -0
  124. package/src/render/program/heatmap_program.js +83 -0
  125. package/src/render/program/hillshade_program.js +119 -0
  126. package/src/render/program/line_program.js +211 -0
  127. package/src/render/program/pattern.js +102 -0
  128. package/src/render/program/program_uniforms.js +42 -0
  129. package/src/render/program/raster_program.js +92 -0
  130. package/src/render/program/symbol_program.js +224 -0
  131. package/src/render/program.js +188 -0
  132. package/src/render/texture.js +122 -0
  133. package/src/render/uniform_binding.js +147 -0
  134. package/src/render/vertex_array_object.js +163 -0
  135. package/src/shaders/README.md +42 -0
  136. package/src/shaders/_prelude.fragment.glsl +17 -0
  137. package/src/shaders/_prelude.vertex.glsl +73 -0
  138. package/src/shaders/background.fragment.glsl +10 -0
  139. package/src/shaders/background.vertex.glsl +7 -0
  140. package/src/shaders/background_pattern.fragment.glsl +28 -0
  141. package/src/shaders/background_pattern.vertex.glsl +20 -0
  142. package/src/shaders/circle.fragment.glsl +39 -0
  143. package/src/shaders/circle.vertex.glsl +64 -0
  144. package/src/shaders/clipping_mask.fragment.glsl +3 -0
  145. package/src/shaders/clipping_mask.vertex.glsl +7 -0
  146. package/src/shaders/collision_box.fragment.glsl +21 -0
  147. package/src/shaders/collision_box.vertex.glsl +27 -0
  148. package/src/shaders/collision_circle.fragment.glsl +17 -0
  149. package/src/shaders/collision_circle.vertex.glsl +59 -0
  150. package/src/shaders/debug.fragment.glsl +9 -0
  151. package/src/shaders/debug.vertex.glsl +12 -0
  152. package/src/shaders/encode_attribute.js +17 -0
  153. package/src/shaders/fill.fragment.glsl +13 -0
  154. package/src/shaders/fill.vertex.glsl +13 -0
  155. package/src/shaders/fill_extrusion.fragment.glsl +9 -0
  156. package/src/shaders/fill_extrusion.vertex.glsl +66 -0
  157. package/src/shaders/fill_extrusion_pattern.fragment.glsl +45 -0
  158. package/src/shaders/fill_extrusion_pattern.vertex.glsl +79 -0
  159. package/src/shaders/fill_outline.fragment.glsl +17 -0
  160. package/src/shaders/fill_outline.vertex.glsl +17 -0
  161. package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
  162. package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
  163. package/src/shaders/fill_pattern.fragment.glsl +36 -0
  164. package/src/shaders/fill_pattern.vertex.glsl +39 -0
  165. package/src/shaders/heatmap.fragment.glsl +22 -0
  166. package/src/shaders/heatmap.vertex.glsl +54 -0
  167. package/src/shaders/heatmap_texture.fragment.glsl +14 -0
  168. package/src/shaders/heatmap_texture.vertex.glsl +11 -0
  169. package/src/shaders/hillshade.fragment.glsl +52 -0
  170. package/src/shaders/hillshade.vertex.glsl +11 -0
  171. package/src/shaders/hillshade_prepare.fragment.glsl +75 -0
  172. package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
  173. package/src/shaders/index.js +20 -0
  174. package/src/shaders/line.fragment.glsl +30 -0
  175. package/src/shaders/line.vertex.glsl +85 -0
  176. package/src/shaders/line_gradient.fragment.glsl +34 -0
  177. package/src/shaders/line_gradient.vertex.glsl +88 -0
  178. package/src/shaders/line_pattern.fragment.glsl +74 -0
  179. package/src/shaders/line_pattern.vertex.glsl +99 -0
  180. package/src/shaders/line_sdf.fragment.glsl +45 -0
  181. package/src/shaders/line_sdf.vertex.glsl +98 -0
  182. package/src/shaders/raster.fragment.glsl +52 -0
  183. package/src/shaders/raster.vertex.glsl +21 -0
  184. package/src/shaders/shaders.js +185 -0
  185. package/src/shaders/symbol_icon.fragment.glsl +17 -0
  186. package/src/shaders/symbol_icon.vertex.glsl +94 -0
  187. package/src/shaders/symbol_sdf.fragment.glsl +52 -0
  188. package/src/shaders/symbol_sdf.vertex.glsl +115 -0
  189. package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
  190. package/src/shaders/symbol_text_and_icon.vertex.glsl +116 -0
  191. package/src/source/canvas_source.js +238 -0
  192. package/src/source/geojson_source.js +370 -0
  193. package/src/source/geojson_worker_source.js +366 -0
  194. package/src/source/geojson_wrapper.js +94 -0
  195. package/src/source/image_source.js +307 -0
  196. package/src/source/load_tilejson.js +39 -0
  197. package/src/source/pixels_to_tile_units.js +21 -0
  198. package/src/source/query_features.js +208 -0
  199. package/src/source/raster_dem_tile_source.js +138 -0
  200. package/src/source/raster_dem_tile_worker_source.js +62 -0
  201. package/src/source/raster_tile_source.js +169 -0
  202. package/src/source/rtl_text_plugin.js +143 -0
  203. package/src/source/source.js +137 -0
  204. package/src/source/source_cache.js +953 -0
  205. package/src/source/source_state.js +159 -0
  206. package/src/source/tile.js +458 -0
  207. package/src/source/tile_bounds.js +38 -0
  208. package/src/source/tile_cache.js +212 -0
  209. package/src/source/tile_id.js +199 -0
  210. package/src/source/vector_tile_source.js +259 -0
  211. package/src/source/vector_tile_worker_source.js +216 -0
  212. package/src/source/video_source.js +203 -0
  213. package/src/source/worker.js +240 -0
  214. package/src/source/worker_source.js +107 -0
  215. package/src/source/worker_tile.js +224 -0
  216. package/src/style/create_style_layer.js +36 -0
  217. package/src/style/evaluation_parameters.js +62 -0
  218. package/src/style/format_section_override.js +56 -0
  219. package/src/style/light.js +130 -0
  220. package/src/style/load_glyph_range.js +38 -0
  221. package/src/style/load_sprite.js +67 -0
  222. package/src/style/parse_glyph_pbf.js +44 -0
  223. package/src/style/pauseable_placement.js +132 -0
  224. package/src/style/properties.js +753 -0
  225. package/src/style/query_utils.js +43 -0
  226. package/src/style/style.js +1374 -0
  227. package/src/style/style_glyph.js +17 -0
  228. package/src/style/style_image.js +137 -0
  229. package/src/style/style_layer/background_style_layer.js +21 -0
  230. package/src/style/style_layer/background_style_layer_properties.js +40 -0
  231. package/src/style/style_layer/circle_style_layer.js +98 -0
  232. package/src/style/style_layer/circle_style_layer_properties.js +63 -0
  233. package/src/style/style_layer/custom_style_layer.js +223 -0
  234. package/src/style/style_layer/fill_extrusion_style_layer.js +224 -0
  235. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +50 -0
  236. package/src/style/style_layer/fill_style_layer.js +67 -0
  237. package/src/style/style_layer/fill_style_layer_properties.js +55 -0
  238. package/src/style/style_layer/heatmap_style_layer.js +73 -0
  239. package/src/style/style_layer/heatmap_style_layer_properties.js +44 -0
  240. package/src/style/style_layer/hillshade_style_layer.js +25 -0
  241. package/src/style/style_layer/hillshade_style_layer_properties.js +46 -0
  242. package/src/style/style_layer/layer_properties.js.ejs +69 -0
  243. package/src/style/style_layer/line_style_layer.js +150 -0
  244. package/src/style/style_layer/line_style_layer_properties.js +71 -0
  245. package/src/style/style_layer/raster_style_layer.js +21 -0
  246. package/src/style/style_layer/raster_style_layer_properties.js +50 -0
  247. package/src/style/style_layer/symbol_style_layer.js +190 -0
  248. package/src/style/style_layer/symbol_style_layer_properties.js +153 -0
  249. package/src/style/style_layer/typed_style_layer.js +17 -0
  250. package/src/style/style_layer.js +283 -0
  251. package/src/style/style_layer_index.js +80 -0
  252. package/src/style/validate_style.js +42 -0
  253. package/src/style/zoom_history.js +44 -0
  254. package/src/style-spec/.eslintrc +5 -0
  255. package/src/style-spec/CHANGELOG.md +468 -0
  256. package/src/style-spec/README.md +59 -0
  257. package/src/style-spec/bin/gl-style-composite +9 -0
  258. package/src/style-spec/bin/gl-style-format +22 -0
  259. package/src/style-spec/bin/gl-style-migrate +9 -0
  260. package/src/style-spec/bin/gl-style-validate +50 -0
  261. package/src/style-spec/composite.js +50 -0
  262. package/src/style-spec/declass.js +42 -0
  263. package/src/style-spec/deref.js +52 -0
  264. package/src/style-spec/diff.js +393 -0
  265. package/src/style-spec/dist/.gitkeep +0 -0
  266. package/src/style-spec/dist/index.es.js +15032 -0
  267. package/src/style-spec/dist/index.es.js.map +1 -0
  268. package/src/style-spec/dist/index.js +15058 -0
  269. package/src/style-spec/dist/index.js.map +1 -0
  270. package/src/style-spec/empty.js +29 -0
  271. package/src/style-spec/error/parsing_error.js +16 -0
  272. package/src/style-spec/error/validation_error.js +18 -0
  273. package/src/style-spec/expression/compound_expression.js +162 -0
  274. package/src/style-spec/expression/definitions/assertion.js +130 -0
  275. package/src/style-spec/expression/definitions/at.js +70 -0
  276. package/src/style-spec/expression/definitions/case.js +85 -0
  277. package/src/style-spec/expression/definitions/coalesce.js +93 -0
  278. package/src/style-spec/expression/definitions/coercion.js +133 -0
  279. package/src/style-spec/expression/definitions/collator.js +78 -0
  280. package/src/style-spec/expression/definitions/comparison.js +184 -0
  281. package/src/style-spec/expression/definitions/format.js +144 -0
  282. package/src/style-spec/expression/definitions/image.js +52 -0
  283. package/src/style-spec/expression/definitions/in.js +72 -0
  284. package/src/style-spec/expression/definitions/index.js +565 -0
  285. package/src/style-spec/expression/definitions/index_of.js +89 -0
  286. package/src/style-spec/expression/definitions/interpolate.js +267 -0
  287. package/src/style-spec/expression/definitions/length.js +61 -0
  288. package/src/style-spec/expression/definitions/let.js +72 -0
  289. package/src/style-spec/expression/definitions/literal.js +77 -0
  290. package/src/style-spec/expression/definitions/match.js +158 -0
  291. package/src/style-spec/expression/definitions/number_format.js +142 -0
  292. package/src/style-spec/expression/definitions/slice.js +86 -0
  293. package/src/style-spec/expression/definitions/step.js +120 -0
  294. package/src/style-spec/expression/definitions/var.js +46 -0
  295. package/src/style-spec/expression/definitions/within.js +342 -0
  296. package/src/style-spec/expression/evaluation_context.js +59 -0
  297. package/src/style-spec/expression/expression.js +27 -0
  298. package/src/style-spec/expression/index.js +392 -0
  299. package/src/style-spec/expression/is_constant.js +59 -0
  300. package/src/style-spec/expression/parsing_context.js +233 -0
  301. package/src/style-spec/expression/parsing_error.js +13 -0
  302. package/src/style-spec/expression/runtime_error.js +17 -0
  303. package/src/style-spec/expression/scope.js +36 -0
  304. package/src/style-spec/expression/stops.js +39 -0
  305. package/src/style-spec/expression/types/collator.js +61 -0
  306. package/src/style-spec/expression/types/formatted.js +73 -0
  307. package/src/style-spec/expression/types/resolved_image.js +29 -0
  308. package/src/style-spec/expression/types.js +126 -0
  309. package/src/style-spec/expression/values.js +123 -0
  310. package/src/style-spec/feature_filter/README.md +55 -0
  311. package/src/style-spec/feature_filter/convert.js +208 -0
  312. package/src/style-spec/feature_filter/index.js +175 -0
  313. package/src/style-spec/format.js +51 -0
  314. package/src/style-spec/function/convert.js +270 -0
  315. package/src/style-spec/function/index.js +262 -0
  316. package/src/style-spec/group_by_layout.js +75 -0
  317. package/src/style-spec/migrate/expressions.js +39 -0
  318. package/src/style-spec/migrate/v8.js +203 -0
  319. package/src/style-spec/migrate/v9.js +26 -0
  320. package/src/style-spec/migrate.js +36 -0
  321. package/src/style-spec/package.json +41 -0
  322. package/src/style-spec/read_style.js +14 -0
  323. package/src/style-spec/reference/latest.js +3 -0
  324. package/src/style-spec/reference/v8.json +5914 -0
  325. package/src/style-spec/rollup.config.js +65 -0
  326. package/src/style-spec/style-spec.js +124 -0
  327. package/src/style-spec/types.js +432 -0
  328. package/src/style-spec/util/color.js +95 -0
  329. package/src/style-spec/util/color_spaces.js +139 -0
  330. package/src/style-spec/util/deep_equal.js +28 -0
  331. package/src/style-spec/util/extend.js +10 -0
  332. package/src/style-spec/util/get_type.js +17 -0
  333. package/src/style-spec/util/interpolate.js +22 -0
  334. package/src/style-spec/util/properties.js +15 -0
  335. package/src/style-spec/util/ref_properties.js +2 -0
  336. package/src/style-spec/util/result.js +19 -0
  337. package/src/style-spec/util/unbundle_jsonlint.js +24 -0
  338. package/src/style-spec/validate/latest.js +11 -0
  339. package/src/style-spec/validate/validate.js +75 -0
  340. package/src/style-spec/validate/validate_array.js +52 -0
  341. package/src/style-spec/validate/validate_boolean.js +15 -0
  342. package/src/style-spec/validate/validate_color.js +20 -0
  343. package/src/style-spec/validate/validate_constants.js +13 -0
  344. package/src/style-spec/validate/validate_enum.js +21 -0
  345. package/src/style-spec/validate/validate_expression.js +43 -0
  346. package/src/style-spec/validate/validate_filter.js +117 -0
  347. package/src/style-spec/validate/validate_formatted.js +11 -0
  348. package/src/style-spec/validate/validate_function.js +207 -0
  349. package/src/style-spec/validate/validate_glyphs_url.js +21 -0
  350. package/src/style-spec/validate/validate_image.js +11 -0
  351. package/src/style-spec/validate/validate_layer.js +134 -0
  352. package/src/style-spec/validate/validate_layout_property.js +6 -0
  353. package/src/style-spec/validate/validate_light.js +47 -0
  354. package/src/style-spec/validate/validate_number.js +29 -0
  355. package/src/style-spec/validate/validate_object.js +61 -0
  356. package/src/style-spec/validate/validate_paint_property.js +6 -0
  357. package/src/style-spec/validate/validate_property.js +64 -0
  358. package/src/style-spec/validate/validate_source.js +111 -0
  359. package/src/style-spec/validate/validate_string.js +15 -0
  360. package/src/style-spec/validate_mapbox_api_supported.js +171 -0
  361. package/src/style-spec/validate_style.js +39 -0
  362. package/src/style-spec/validate_style.min.js +78 -0
  363. package/src/style-spec/visit.js +77 -0
  364. package/src/symbol/anchor.js +26 -0
  365. package/src/symbol/check_max_angle.js +81 -0
  366. package/src/symbol/clip_line.js +71 -0
  367. package/src/symbol/collision_feature.js +109 -0
  368. package/src/symbol/collision_index.js +373 -0
  369. package/src/symbol/cross_tile_symbol_index.js +301 -0
  370. package/src/symbol/get_anchors.js +167 -0
  371. package/src/symbol/grid_index.js +335 -0
  372. package/src/symbol/mergelines.js +82 -0
  373. package/src/symbol/one_em.js +4 -0
  374. package/src/symbol/opacity_state.js +27 -0
  375. package/src/symbol/path_interpolator.js +61 -0
  376. package/src/symbol/placement.js +1124 -0
  377. package/src/symbol/projection.js +451 -0
  378. package/src/symbol/quads.js +334 -0
  379. package/src/symbol/shaping.js +816 -0
  380. package/src/symbol/symbol_layout.js +796 -0
  381. package/src/symbol/symbol_size.js +113 -0
  382. package/src/symbol/transform_text.js +29 -0
  383. package/src/types/callback.js +17 -0
  384. package/src/types/cancelable.js +3 -0
  385. package/src/types/tilejson.js +17 -0
  386. package/src/types/transferable.js +3 -0
  387. package/src/types/window.js +172 -0
  388. package/src/ui/anchor.js +32 -0
  389. package/src/ui/camera.js +1277 -0
  390. package/src/ui/control/attribution_control.js +212 -0
  391. package/src/ui/control/fullscreen_control.js +147 -0
  392. package/src/ui/control/geolocate_control.js +707 -0
  393. package/src/ui/control/logo_control.js +92 -0
  394. package/src/ui/control/navigation_control.js +257 -0
  395. package/src/ui/control/scale_control.js +142 -0
  396. package/src/ui/default_locale.js +22 -0
  397. package/src/ui/events.js +1301 -0
  398. package/src/ui/handler/box_zoom.js +170 -0
  399. package/src/ui/handler/click_zoom.js +52 -0
  400. package/src/ui/handler/handler_util.js +12 -0
  401. package/src/ui/handler/keyboard.js +208 -0
  402. package/src/ui/handler/map_event.js +156 -0
  403. package/src/ui/handler/mouse.js +171 -0
  404. package/src/ui/handler/scroll_zoom.js +350 -0
  405. package/src/ui/handler/shim/dblclick_zoom.js +62 -0
  406. package/src/ui/handler/shim/drag_pan.js +88 -0
  407. package/src/ui/handler/shim/drag_rotate.js +67 -0
  408. package/src/ui/handler/shim/touch_zoom_rotate.js +108 -0
  409. package/src/ui/handler/tap_drag_zoom.js +103 -0
  410. package/src/ui/handler/tap_recognizer.js +133 -0
  411. package/src/ui/handler/tap_zoom.js +93 -0
  412. package/src/ui/handler/touch_pan.js +101 -0
  413. package/src/ui/handler/touch_zoom_rotate.js +305 -0
  414. package/src/ui/handler_inertia.js +158 -0
  415. package/src/ui/handler_manager.js +531 -0
  416. package/src/ui/hash.js +148 -0
  417. package/src/ui/map.js +2874 -0
  418. package/src/ui/marker.js +672 -0
  419. package/src/ui/popup.js +640 -0
  420. package/src/util/actor.js +212 -0
  421. package/src/util/ajax.js +388 -0
  422. package/src/util/browser/web_worker.js +10 -0
  423. package/src/util/browser/window.js +6 -0
  424. package/src/util/browser.js +70 -0
  425. package/src/util/classify_rings.js +52 -0
  426. package/src/util/color_ramp.js +61 -0
  427. package/src/util/config.js +30 -0
  428. package/src/util/debug.js +28 -0
  429. package/src/util/dictionary_coder.js +30 -0
  430. package/src/util/dispatcher.js +70 -0
  431. package/src/util/dom.js +142 -0
  432. package/src/util/evented.js +174 -0
  433. package/src/util/find_pole_of_inaccessibility.js +129 -0
  434. package/src/util/global_worker_pool.js +35 -0
  435. package/src/util/image.js +142 -0
  436. package/src/util/intersection_tests.js +208 -0
  437. package/src/util/is_char_in_unicode_block.js +311 -0
  438. package/src/util/mapbox.js +491 -0
  439. package/src/util/offscreen_canvas_supported.js +14 -0
  440. package/src/util/performance.js +112 -0
  441. package/src/util/primitives.js +145 -0
  442. package/src/util/resolve_tokens.js +16 -0
  443. package/src/util/script_detection.js +328 -0
  444. package/src/util/sku_token.js +42 -0
  445. package/src/util/smart_wrap.js +55 -0
  446. package/src/util/struct_array.js +243 -0
  447. package/src/util/struct_array.js.ejs +112 -0
  448. package/src/util/struct_array_layout.js.ejs +98 -0
  449. package/src/util/task_queue.js +68 -0
  450. package/src/util/throttle.js +27 -0
  451. package/src/util/throttled_invoker.js +46 -0
  452. package/src/util/tile_request_cache.js +172 -0
  453. package/src/util/util.js +524 -0
  454. package/src/util/vectortile_to_geojson.js +50 -0
  455. package/src/util/verticalize_punctuation.js +114 -0
  456. package/src/util/web_worker.js +91 -0
  457. package/src/util/web_worker_transfer.js +266 -0
  458. package/src/util/webp_supported.js +69 -0
  459. package/src/util/window.js +102 -0
  460. package/src/util/worker_pool.js +57 -0
@@ -0,0 +1,7 @@
1
+ // @flow
2
+ import {createLayout} from '../util/struct_array';
3
+
4
+ export default createLayout([
5
+ {name: 'a_pos', type: 'Int16', components: 2},
6
+ {name: 'a_texture_pos', type: 'Int16', components: 2}
7
+ ]);
@@ -0,0 +1,76 @@
1
+ // @flow
2
+
3
+ import {warnOnce} from '../util/util';
4
+
5
+ import {register} from '../util/web_worker_transfer';
6
+
7
+ import type VertexArrayObject from '../render/vertex_array_object';
8
+ import type {StructArray} from '../util/struct_array';
9
+
10
+ export type Segment = {
11
+ sortKey: number | void,
12
+ vertexOffset: number,
13
+ primitiveOffset: number,
14
+ vertexLength: number,
15
+ primitiveLength: number,
16
+ vaos: {[_: string]: VertexArrayObject}
17
+ }
18
+
19
+ class SegmentVector {
20
+ static MAX_VERTEX_ARRAY_LENGTH: number;
21
+ segments: Array<Segment>;
22
+
23
+ constructor(segments?: Array<Segment> = []) {
24
+ this.segments = segments;
25
+ }
26
+
27
+ prepareSegment(numVertices: number, layoutVertexArray: StructArray, indexArray: StructArray, sortKey?: number): Segment {
28
+ let segment: Segment = this.segments[this.segments.length - 1];
29
+ if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`);
30
+ if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {
31
+ segment = ({
32
+ vertexOffset: layoutVertexArray.length,
33
+ primitiveOffset: indexArray.length,
34
+ vertexLength: 0,
35
+ primitiveLength: 0
36
+ }: any);
37
+ if (sortKey !== undefined) segment.sortKey = sortKey;
38
+ this.segments.push(segment);
39
+ }
40
+ return segment;
41
+ }
42
+
43
+ get() {
44
+ return this.segments;
45
+ }
46
+
47
+ destroy() {
48
+ for (const segment of this.segments) {
49
+ for (const k in segment.vaos) {
50
+ segment.vaos[k].destroy();
51
+ }
52
+ }
53
+ }
54
+
55
+ static simpleSegment(vertexOffset: number, primitiveOffset: number, vertexLength: number, primitiveLength: number): SegmentVector {
56
+ return new SegmentVector([{
57
+ vertexOffset,
58
+ primitiveOffset,
59
+ vertexLength,
60
+ primitiveLength,
61
+ vaos: {},
62
+ sortKey: 0
63
+ }]);
64
+ }
65
+ }
66
+
67
+ /*
68
+ * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit
69
+ * addressing of vertex buffers.
70
+ * @private
71
+ * @readonly
72
+ */
73
+ SegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;
74
+
75
+ register('SegmentVector', SegmentVector);
76
+ export default SegmentVector;
@@ -0,0 +1,102 @@
1
+ // @flow
2
+ import {number} from "../style-spec/util/interpolate";
3
+ import Point from "@mapbox/point-geometry";
4
+ import {clamp} from "../util/util";
5
+
6
+ /**
7
+ * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
8
+ * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
9
+ * on top of the map and having the vanishing point shift as UI elements resize.
10
+ *
11
+ * @param {number} [top=0]
12
+ * @param {number} [bottom=0]
13
+ * @param {number} [left=0]
14
+ * @param {number} [right=0]
15
+ */
16
+ class EdgeInsets {
17
+ top: number;
18
+ bottom: number;
19
+ left: number;
20
+ right: number;
21
+
22
+ constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) {
23
+ if (isNaN(top) || top < 0 ||
24
+ isNaN(bottom) || bottom < 0 ||
25
+ isNaN(left) || left < 0 ||
26
+ isNaN(right) || right < 0
27
+ ) {
28
+ throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
29
+ }
30
+
31
+ this.top = top;
32
+ this.bottom = bottom;
33
+ this.left = left;
34
+ this.right = right;
35
+ }
36
+
37
+ /**
38
+ * Interpolates the inset in-place.
39
+ * This maintains the current inset value for any inset not present in `target`.
40
+ *
41
+ * @param {PaddingOptions} target
42
+ * @param {number} t
43
+ * @returns {EdgeInsets}
44
+ * @memberof EdgeInsets
45
+ */
46
+ interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets {
47
+ if (target.top != null && start.top != null) this.top = number(start.top, target.top, t);
48
+ if (target.bottom != null && start.bottom != null) this.bottom = number(start.bottom, target.bottom, t);
49
+ if (target.left != null && start.left != null) this.left = number(start.left, target.left, t);
50
+ if (target.right != null && start.right != null) this.right = number(start.right, target.right, t);
51
+
52
+ return this;
53
+ }
54
+
55
+ /**
56
+ * Utility method that computes the new apprent center or vanishing point after applying insets.
57
+ * This is in pixels and with the top left being (0.0) and +y being downwards.
58
+ *
59
+ * @param {number} width
60
+ * @param {number} height
61
+ * @returns {Point}
62
+ * @memberof EdgeInsets
63
+ */
64
+ getCenter(width: number, height: number): Point {
65
+ // Clamp insets so they never overflow width/height and always calculate a valid center
66
+ const x = clamp((this.left + width - this.right) / 2, 0, width);
67
+ const y = clamp((this.top + height - this.bottom) / 2, 0, height);
68
+
69
+ return new Point(x, y);
70
+ }
71
+
72
+ equals(other: PaddingOptions): boolean {
73
+ return this.top === other.top &&
74
+ this.bottom === other.bottom &&
75
+ this.left === other.left &&
76
+ this.right === other.right;
77
+ }
78
+
79
+ clone(): EdgeInsets {
80
+ return new EdgeInsets(this.top, this.bottom, this.left, this.right);
81
+ }
82
+
83
+ /**
84
+ * Returns the current sdtate as json, useful when you want to have a
85
+ * read-only representation of the inset.
86
+ *
87
+ * @returns {PaddingOptions}
88
+ * @memberof EdgeInsets
89
+ */
90
+ toJSON(): PaddingOptions {
91
+ return {
92
+ top: this.top,
93
+ bottom: this.bottom,
94
+ left: this.left,
95
+ right: this.right
96
+ };
97
+ }
98
+ }
99
+
100
+ export type PaddingOptions = {top: ?number, bottom: ?number, right: ?number, left: ?number};
101
+
102
+ export default EdgeInsets;
@@ -0,0 +1,168 @@
1
+ // @flow
2
+
3
+ import {wrap} from '../util/util';
4
+ import LngLatBounds from './lng_lat_bounds';
5
+
6
+ /*
7
+ * Approximate radius of the earth in meters.
8
+ * 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
9
+ * 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
10
+ */
11
+ export const earthRadius = 6371008.8;
12
+
13
+ /**
14
+ * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
15
+ * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
16
+ *
17
+ * Mapbox GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
18
+ * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
19
+ *
20
+ * Note that any Mapbox GL method that accepts a `LngLat` object as an argument or option
21
+ * can also accept an `Array` of two numbers and will perform an implicit conversion.
22
+ * This flexible type is documented as {@link LngLatLike}.
23
+ *
24
+ * @param {number} lng Longitude, measured in degrees.
25
+ * @param {number} lat Latitude, measured in degrees.
26
+ * @example
27
+ * var ll = new mapboxgl.LngLat(-123.9749, 40.7736);
28
+ * ll.lng; // = -123.9749
29
+ * @see [Get coordinates of the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/mouse-position/)
30
+ * @see [Display a popup](https://www.mapbox.com/mapbox-gl-js/example/popup/)
31
+ * @see [Highlight features within a bounding box](https://www.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)
32
+ * @see [Create a timeline animation](https://www.mapbox.com/mapbox-gl-js/example/timeline-animation/)
33
+ */
34
+ class LngLat {
35
+ lng: number;
36
+ lat: number;
37
+
38
+ constructor(lng: number, lat: number) {
39
+ if (isNaN(lng) || isNaN(lat)) {
40
+ throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
41
+ }
42
+ this.lng = +lng;
43
+ this.lat = +lat;
44
+ if (this.lat > 90 || this.lat < -90) {
45
+ throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
51
+ *
52
+ * @returns {LngLat} The wrapped `LngLat` object.
53
+ * @example
54
+ * var ll = new mapboxgl.LngLat(286.0251, 40.7736);
55
+ * var wrapped = ll.wrap();
56
+ * wrapped.lng; // = -73.9749
57
+ */
58
+ wrap() {
59
+ return new LngLat(wrap(this.lng, -180, 180), this.lat);
60
+ }
61
+
62
+ /**
63
+ * Returns the coordinates represented as an array of two numbers.
64
+ *
65
+ * @returns {Array<number>} The coordinates represeted as an array of longitude and latitude.
66
+ * @example
67
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
68
+ * ll.toArray(); // = [-73.9749, 40.7736]
69
+ */
70
+ toArray() {
71
+ return [this.lng, this.lat];
72
+ }
73
+
74
+ /**
75
+ * Returns the coordinates represent as a string.
76
+ *
77
+ * @returns {string} The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
78
+ * @example
79
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
80
+ * ll.toString(); // = "LngLat(-73.9749, 40.7736)"
81
+ */
82
+ toString() {
83
+ return `LngLat(${this.lng}, ${this.lat})`;
84
+ }
85
+
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} lngLat coordinates to compute the distance to
91
+ * @returns {number} Distance in meters between the two coordinates.
92
+ * @example
93
+ * var new_york = new mapboxgl.LngLat(-74.0060, 40.7128);
94
+ * var los_angeles = new mapboxgl.LngLat(-118.2437, 34.0522);
95
+ * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
96
+ */
97
+ distanceTo(lngLat: LngLat) {
98
+ const rad = Math.PI / 180;
99
+ const lat1 = this.lat * rad;
100
+ const lat2 = lngLat.lat * rad;
101
+ const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
102
+
103
+ const maxMeters = earthRadius * Math.acos(Math.min(a, 1));
104
+ return maxMeters;
105
+ }
106
+
107
+ /**
108
+ * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.
109
+ *
110
+ * @param {number} [radius=0] Distance in meters from the coordinates to extend the bounds.
111
+ * @returns {LngLatBounds} A new `LngLatBounds` object representing the coordinates extended by the `radius`.
112
+ * @example
113
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
114
+ * ll.toBounds(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
115
+ */
116
+ toBounds(radius?: number = 0) {
117
+ const earthCircumferenceInMetersAtEquator = 40075017;
118
+ const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator,
119
+ lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
120
+
121
+ return new LngLatBounds(new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
122
+ new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy));
123
+ }
124
+
125
+ /**
126
+ * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties
127
+ * to a `LngLat` object.
128
+ *
129
+ * If a `LngLat` object is passed in, the function returns it unchanged.
130
+ *
131
+ * @param {LngLatLike} input An array of two numbers or object to convert, or a `LngLat` object to return.
132
+ * @returns {LngLat} A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
133
+ * @example
134
+ * var arr = [-73.9749, 40.7736];
135
+ * var ll = mapboxgl.LngLat.convert(arr);
136
+ * ll; // = LngLat {lng: -73.9749, lat: 40.7736}
137
+ */
138
+ static convert(input: LngLatLike): LngLat {
139
+ if (input instanceof LngLat) {
140
+ return input;
141
+ }
142
+ if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
143
+ return new LngLat(Number(input[0]), Number(input[1]));
144
+ }
145
+ if (!Array.isArray(input) && typeof input === 'object' && input !== null) {
146
+ return new LngLat(
147
+ // flow can't refine this to have one of lng or lat, so we have to cast to any
148
+ Number('lng' in input ? (input: any).lng : (input: any).lon),
149
+ Number(input.lat)
150
+ );
151
+ }
152
+ 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>]");
153
+ }
154
+ }
155
+
156
+ /**
157
+ * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
158
+ * or an object with `lng` and `lat` or `lon` and `lat` properties.
159
+ *
160
+ * @typedef {LngLat | {lng: number, lat: number} | {lon: number, lat: number} | [number, number]} LngLatLike
161
+ * @example
162
+ * var v1 = new mapboxgl.LngLat(-122.420679, 37.772537);
163
+ * var v2 = [-122.420679, 37.772537];
164
+ * var v3 = {lon: -122.420679, lat: 37.772537};
165
+ */
166
+ export type LngLatLike = LngLat | {lng: number, lat: number} | {lon: number, lat: number} | [number, number];
167
+
168
+ export default LngLat;
@@ -0,0 +1,276 @@
1
+ // @flow
2
+
3
+ import LngLat from './lng_lat';
4
+
5
+ import type {LngLatLike} from './lng_lat';
6
+
7
+ /**
8
+ * A `LngLatBounds` object represents a geographical bounding box,
9
+ * defined by its southwest and northeast points in longitude and latitude.
10
+ *
11
+ * If no arguments are provided to the constructor, a `null` bounding box is created.
12
+ *
13
+ * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option
14
+ * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.
15
+ * This flexible type is documented as {@link LngLatBoundsLike}.
16
+ *
17
+ * @param {LngLatLike} [sw] The southwest corner of the bounding box.
18
+ * @param {LngLatLike} [ne] The northeast corner of the bounding box.
19
+ * @example
20
+ * var sw = new mapboxgl.LngLat(-73.9876, 40.7661);
21
+ * var ne = new mapboxgl.LngLat(-73.9397, 40.8002);
22
+ * var llb = new mapboxgl.LngLatBounds(sw, ne);
23
+ */
24
+ class LngLatBounds {
25
+ _ne: LngLat;
26
+ _sw: LngLat;
27
+
28
+ // This constructor is too flexible to type. It should not be so flexible.
29
+ constructor(sw: any, ne: any) {
30
+ if (!sw) {
31
+ // noop
32
+ } else if (ne) {
33
+ this.setSouthWest(sw).setNorthEast(ne);
34
+ } else if (sw.length === 4) {
35
+ this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
36
+ } else {
37
+ this.setSouthWest(sw[0]).setNorthEast(sw[1]);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Set the northeast corner of the bounding box
43
+ *
44
+ * @param {LngLatLike} ne a {@link LngLatLike} object describing the northeast corner of the bounding box.
45
+ * @returns {LngLatBounds} `this`
46
+ */
47
+ setNorthEast(ne: LngLatLike) {
48
+ this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);
49
+ return this;
50
+ }
51
+
52
+ /**
53
+ * Set the southwest corner of the bounding box
54
+ *
55
+ * @param {LngLatLike} sw a {@link LngLatLike} object describing the southwest corner of the bounding box.
56
+ * @returns {LngLatBounds} `this`
57
+ */
58
+ setSouthWest(sw: LngLatLike) {
59
+ this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);
60
+ return this;
61
+ }
62
+
63
+ /**
64
+ * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.
65
+ *
66
+ * @param {LngLatLike|LngLatBoundsLike} obj object to extend to
67
+ * @returns {LngLatBounds} `this`
68
+ */
69
+ extend(obj: LngLatLike | LngLatBoundsLike) {
70
+ const sw = this._sw,
71
+ ne = this._ne;
72
+ let sw2, ne2;
73
+
74
+ if (obj instanceof LngLat) {
75
+ sw2 = obj;
76
+ ne2 = obj;
77
+
78
+ } else if (obj instanceof LngLatBounds) {
79
+ sw2 = obj._sw;
80
+ ne2 = obj._ne;
81
+
82
+ if (!sw2 || !ne2) return this;
83
+
84
+ } else {
85
+ if (Array.isArray(obj)) {
86
+ if (obj.length === 4 || obj.every(Array.isArray)) {
87
+ const lngLatBoundsObj = ((obj: any): LngLatBoundsLike);
88
+ return this.extend(LngLatBounds.convert(lngLatBoundsObj));
89
+ } else {
90
+ const lngLatObj = ((obj: any): LngLatLike);
91
+ return this.extend(LngLat.convert(lngLatObj));
92
+ }
93
+ }
94
+ return this;
95
+ }
96
+
97
+ if (!sw && !ne) {
98
+ this._sw = new LngLat(sw2.lng, sw2.lat);
99
+ this._ne = new LngLat(ne2.lng, ne2.lat);
100
+
101
+ } else {
102
+ sw.lng = Math.min(sw2.lng, sw.lng);
103
+ sw.lat = Math.min(sw2.lat, sw.lat);
104
+ ne.lng = Math.max(ne2.lng, ne.lng);
105
+ ne.lat = Math.max(ne2.lat, ne.lat);
106
+ }
107
+
108
+ return this;
109
+ }
110
+
111
+ /**
112
+ * Returns the geographical coordinate equidistant from the bounding box's corners.
113
+ *
114
+ * @returns {LngLat} The bounding box's center.
115
+ * @example
116
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
117
+ * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
118
+ */
119
+ getCenter(): LngLat {
120
+ return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
121
+ }
122
+
123
+ /**
124
+ * Returns the southwest corner of the bounding box.
125
+ *
126
+ * @returns {LngLat} The southwest corner of the bounding box.
127
+ */
128
+ getSouthWest(): LngLat { return this._sw; }
129
+
130
+ /**
131
+ * Returns the northeast corner of the bounding box.
132
+ *
133
+ * @returns {LngLat} The northeast corner of the bounding box.
134
+ */
135
+ getNorthEast(): LngLat { return this._ne; }
136
+
137
+ /**
138
+ * Returns the northwest corner of the bounding box.
139
+ *
140
+ * @returns {LngLat} The northwest corner of the bounding box.
141
+ */
142
+ getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); }
143
+
144
+ /**
145
+ * Returns the southeast corner of the bounding box.
146
+ *
147
+ * @returns {LngLat} The southeast corner of the bounding box.
148
+ */
149
+ getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); }
150
+
151
+ /**
152
+ * Returns the west edge of the bounding box.
153
+ *
154
+ * @returns {number} The west edge of the bounding box.
155
+ */
156
+ getWest(): number { return this._sw.lng; }
157
+
158
+ /**
159
+ * Returns the south edge of the bounding box.
160
+ *
161
+ * @returns {number} The south edge of the bounding box.
162
+ */
163
+ getSouth(): number { return this._sw.lat; }
164
+
165
+ /**
166
+ * Returns the east edge of the bounding box.
167
+ *
168
+ * @returns {number} The east edge of the bounding box.
169
+ */
170
+ getEast(): number { return this._ne.lng; }
171
+
172
+ /**
173
+ * Returns the north edge of the bounding box.
174
+ *
175
+ * @returns {number} The north edge of the bounding box.
176
+ */
177
+ getNorth(): number { return this._ne.lat; }
178
+
179
+ /**
180
+ * Returns the bounding box represented as an array.
181
+ *
182
+ * @returns {Array<Array<number>>} The bounding box represented as an array, consisting of the
183
+ * southwest and northeast coordinates of the bounding represented as arrays of numbers.
184
+ * @example
185
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
186
+ * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
187
+ */
188
+ toArray() {
189
+ return [this._sw.toArray(), this._ne.toArray()];
190
+ }
191
+
192
+ /**
193
+ * Return the bounding box represented as a string.
194
+ *
195
+ * @returns {string} The bounding box represents as a string of the format
196
+ * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
197
+ * @example
198
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
199
+ * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
200
+ */
201
+ toString() {
202
+ return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
203
+ }
204
+
205
+ /**
206
+ * Check if the bounding box is an empty/`null`-type box.
207
+ *
208
+ * @returns {boolean} True if bounds have been defined, otherwise false.
209
+ */
210
+ isEmpty() {
211
+ return !(this._sw && this._ne);
212
+ }
213
+
214
+ /**
215
+ * Check if the point is within the bounding box.
216
+ *
217
+ * @param {LngLatLike} lnglat geographic point to check against.
218
+ * @returns {boolean} True if the point is within the bounding box.
219
+ * @example
220
+ * var llb = new mapboxgl.LngLatBounds(
221
+ * new mapboxgl.LngLat(-73.9876, 40.7661),
222
+ * new mapboxgl.LngLat(-73.9397, 40.8002)
223
+ * );
224
+ *
225
+ * var ll = new mapboxgl.LngLat(-73.9567, 40.7789);
226
+ *
227
+ * console.log(llb.contains(ll)); // = true
228
+ */
229
+ contains(lnglat: LngLatLike) {
230
+ const {lng, lat} = LngLat.convert(lnglat);
231
+
232
+ const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat;
233
+ let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng;
234
+ if (this._sw.lng > this._ne.lng) { // wrapped coordinates
235
+ containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng;
236
+ }
237
+
238
+ return containsLatitude && containsLongitude;
239
+ }
240
+
241
+ /**
242
+ * Converts an array to a `LngLatBounds` object.
243
+ *
244
+ * If a `LngLatBounds` object is passed in, the function returns it unchanged.
245
+ *
246
+ * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.
247
+ *
248
+ * @param {LngLatBoundsLike} input An array of two coordinates to convert, or a `LngLatBounds` object to return.
249
+ * @returns {LngLatBounds} A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
250
+ * @example
251
+ * var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
252
+ * var llb = mapboxgl.LngLatBounds.convert(arr);
253
+ * llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
254
+ */
255
+ static convert(input: LngLatBoundsLike): LngLatBounds {
256
+ if (!input || input instanceof LngLatBounds) return input;
257
+ return new LngLatBounds(input);
258
+ }
259
+ }
260
+
261
+ /**
262
+ * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,
263
+ * or an array of numbers in [west, south, east, north] order.
264
+ *
265
+ * @typedef {LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]} LngLatBoundsLike
266
+ * @example
267
+ * var v1 = new mapboxgl.LngLatBounds(
268
+ * new mapboxgl.LngLat(-73.9876, 40.7661),
269
+ * new mapboxgl.LngLat(-73.9397, 40.8002)
270
+ * );
271
+ * var v2 = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
272
+ * var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
273
+ */
274
+ export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];
275
+
276
+ export default LngLatBounds;