@scoova/mgl 1.0.0

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 (565) hide show
  1. package/LICENSE.txt +116 -0
  2. package/README.md +174 -0
  3. package/build/banner.ts +12 -0
  4. package/build/bump-version-changelog.js +26 -0
  5. package/build/check-bundle-size.js +77 -0
  6. package/build/generate-dist-package.js +26 -0
  7. package/build/generate-doc-images.ts +78 -0
  8. package/build/generate-docs.ts +190 -0
  9. package/build/generate-shaders.ts +68 -0
  10. package/build/generate-struct-arrays.ts +438 -0
  11. package/build/generate-style-code.ts +283 -0
  12. package/build/readme.md +56 -0
  13. package/build/release-notes.js +45 -0
  14. package/build/rollup/bundle_prelude.js +29 -0
  15. package/build/rollup/maplibregl.js +22 -0
  16. package/build/rollup_plugins.ts +58 -0
  17. package/dist/LICENSE.txt +116 -0
  18. package/dist/maplibre-gl.css +1 -0
  19. package/dist/maplibre-gl.d.ts +13304 -0
  20. package/dist/maplibre-gl.js +59 -0
  21. package/dist/maplibre-gl.js.map +1 -0
  22. package/dist/package.json +1 -0
  23. package/package.json +192 -0
  24. package/src/css/maplibre-gl.css +854 -0
  25. package/src/css/svg/maplibregl-ctrl-attrib.svg +3 -0
  26. package/src/css/svg/maplibregl-ctrl-compass.svg +4 -0
  27. package/src/css/svg/maplibregl-ctrl-fullscreen.svg +3 -0
  28. package/src/css/svg/maplibregl-ctrl-geolocate.svg +5 -0
  29. package/src/css/svg/maplibregl-ctrl-logo.svg +11 -0
  30. package/src/css/svg/maplibregl-ctrl-shrink.svg +3 -0
  31. package/src/css/svg/maplibregl-ctrl-terrain.svg +3 -0
  32. package/src/css/svg/maplibregl-ctrl-zoom-in.svg +3 -0
  33. package/src/css/svg/maplibregl-ctrl-zoom-out.svg +3 -0
  34. package/src/data/array_types.g.ts +1130 -0
  35. package/src/data/bucket/circle_attributes.ts +8 -0
  36. package/src/data/bucket/circle_bucket.ts +197 -0
  37. package/src/data/bucket/fill_attributes.ts +8 -0
  38. package/src/data/bucket/fill_bucket.test.ts +95 -0
  39. package/src/data/bucket/fill_bucket.ts +228 -0
  40. package/src/data/bucket/fill_extrusion_attributes.ts +13 -0
  41. package/src/data/bucket/fill_extrusion_bucket.ts +305 -0
  42. package/src/data/bucket/heatmap_bucket.ts +12 -0
  43. package/src/data/bucket/line_attributes.ts +8 -0
  44. package/src/data/bucket/line_attributes_ext.ts +8 -0
  45. package/src/data/bucket/line_bucket.test.ts +142 -0
  46. package/src/data/bucket/line_bucket.ts +592 -0
  47. package/src/data/bucket/pattern_attributes.ts +9 -0
  48. package/src/data/bucket/pattern_bucket_features.ts +57 -0
  49. package/src/data/bucket/symbol_attributes.ts +122 -0
  50. package/src/data/bucket/symbol_bucket.test.ts +243 -0
  51. package/src/data/bucket/symbol_bucket.ts +975 -0
  52. package/src/data/bucket.ts +123 -0
  53. package/src/data/dem_data.test.ts +237 -0
  54. package/src/data/dem_data.ts +171 -0
  55. package/src/data/evaluation_feature.ts +18 -0
  56. package/src/data/extent.ts +13 -0
  57. package/src/data/feature_index.ts +337 -0
  58. package/src/data/feature_position_map.test.ts +33 -0
  59. package/src/data/feature_position_map.ts +126 -0
  60. package/src/data/index_array_type.ts +9 -0
  61. package/src/data/load_geometry.test.ts +49 -0
  62. package/src/data/load_geometry.ts +44 -0
  63. package/src/data/pos3d_attributes.ts +5 -0
  64. package/src/data/pos_attributes.ts +5 -0
  65. package/src/data/program_configuration.ts +735 -0
  66. package/src/data/raster_bounds_attributes.ts +6 -0
  67. package/src/data/segment.ts +89 -0
  68. package/src/geo/edge_insets.test.ts +83 -0
  69. package/src/geo/edge_insets.ts +146 -0
  70. package/src/geo/lng_lat.test.ts +65 -0
  71. package/src/geo/lng_lat.ts +169 -0
  72. package/src/geo/lng_lat_bounds.test.ts +357 -0
  73. package/src/geo/lng_lat_bounds.ts +356 -0
  74. package/src/geo/mercator_coordinate.test.ts +34 -0
  75. package/src/geo/mercator_coordinate.ts +157 -0
  76. package/src/geo/projection/projection.ts +72 -0
  77. package/src/geo/transform.test.ts +509 -0
  78. package/src/geo/transform.ts +1072 -0
  79. package/src/gl/color_mode.ts +31 -0
  80. package/src/gl/context.ts +321 -0
  81. package/src/gl/cull_face_mode.ts +22 -0
  82. package/src/gl/depth_mode.ts +26 -0
  83. package/src/gl/framebuffer.ts +48 -0
  84. package/src/gl/index_buffer.ts +55 -0
  85. package/src/gl/render_pool.test.ts +69 -0
  86. package/src/gl/render_pool.ts +93 -0
  87. package/src/gl/state.test.ts +125 -0
  88. package/src/gl/stencil_mode.ts +27 -0
  89. package/src/gl/types.ts +59 -0
  90. package/src/gl/value.ts +534 -0
  91. package/src/gl/vertex_buffer.test.ts +57 -0
  92. package/src/gl/vertex_buffer.ts +111 -0
  93. package/src/gl/webgl2.ts +12 -0
  94. package/src/index.test.ts +121 -0
  95. package/src/index.ts +250 -0
  96. package/src/render/draw_background.ts +53 -0
  97. package/src/render/draw_circle.ts +113 -0
  98. package/src/render/draw_collision_debug.ts +168 -0
  99. package/src/render/draw_custom.test.ts +73 -0
  100. package/src/render/draw_custom.ts +45 -0
  101. package/src/render/draw_debug.test.ts +122 -0
  102. package/src/render/draw_debug.ts +148 -0
  103. package/src/render/draw_fill.test.ts +137 -0
  104. package/src/render/draw_fill.ts +128 -0
  105. package/src/render/draw_fill_extrusion.ts +97 -0
  106. package/src/render/draw_heatmap.ts +228 -0
  107. package/src/render/draw_hillshade.ts +119 -0
  108. package/src/render/draw_line.ts +125 -0
  109. package/src/render/draw_raster.ts +133 -0
  110. package/src/render/draw_sky.ts +44 -0
  111. package/src/render/draw_symbol.test.ts +223 -0
  112. package/src/render/draw_symbol.ts +499 -0
  113. package/src/render/draw_terrain.ts +99 -0
  114. package/src/render/glyph_atlas.ts +83 -0
  115. package/src/render/glyph_manager.test.ts +147 -0
  116. package/src/render/glyph_manager.ts +198 -0
  117. package/src/render/image_atlas.ts +159 -0
  118. package/src/render/image_manager.ts +337 -0
  119. package/src/render/line_atlas.test.ts +38 -0
  120. package/src/render/line_atlas.ts +214 -0
  121. package/src/render/mesh.ts +25 -0
  122. package/src/render/painter.test.ts +51 -0
  123. package/src/render/painter.ts +666 -0
  124. package/src/render/program/background_program.ts +100 -0
  125. package/src/render/program/circle_program.ts +61 -0
  126. package/src/render/program/clipping_mask_program.ts +19 -0
  127. package/src/render/program/collision_program.ts +47 -0
  128. package/src/render/program/debug_program.ts +29 -0
  129. package/src/render/program/fill_extrusion_program.ts +120 -0
  130. package/src/render/program/fill_program.ts +121 -0
  131. package/src/render/program/heatmap_program.ts +76 -0
  132. package/src/render/program/hillshade_program.ts +116 -0
  133. package/src/render/program/line_program.ts +207 -0
  134. package/src/render/program/pattern.ts +102 -0
  135. package/src/render/program/program_uniforms.ts +46 -0
  136. package/src/render/program/raster_program.ts +88 -0
  137. package/src/render/program/sky_program.ts +28 -0
  138. package/src/render/program/symbol_program.ts +266 -0
  139. package/src/render/program/terrain_program.ts +116 -0
  140. package/src/render/program.ts +233 -0
  141. package/src/render/render_to_texture.test.ts +151 -0
  142. package/src/render/render_to_texture.ts +197 -0
  143. package/src/render/terrain.test.ts +322 -0
  144. package/src/render/terrain.ts +464 -0
  145. package/src/render/texture.ts +114 -0
  146. package/src/render/uniform_binding.test.ts +122 -0
  147. package/src/render/uniform_binding.ts +157 -0
  148. package/src/render/update_pattern_positions_in_program.test.ts +74 -0
  149. package/src/render/update_pattern_positions_in_program.ts +50 -0
  150. package/src/render/vertex_array_object.ts +163 -0
  151. package/src/shaders/README.md +42 -0
  152. package/src/shaders/_prelude.fragment.glsl +19 -0
  153. package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
  154. package/src/shaders/_prelude.vertex.glsl +148 -0
  155. package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
  156. package/src/shaders/background.fragment.glsl +10 -0
  157. package/src/shaders/background.fragment.glsl.g.ts +2 -0
  158. package/src/shaders/background.vertex.glsl +7 -0
  159. package/src/shaders/background.vertex.glsl.g.ts +2 -0
  160. package/src/shaders/background_pattern.fragment.glsl +28 -0
  161. package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
  162. package/src/shaders/background_pattern.vertex.glsl +19 -0
  163. package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
  164. package/src/shaders/circle.fragment.glsl +34 -0
  165. package/src/shaders/circle.fragment.glsl.g.ts +2 -0
  166. package/src/shaders/circle.vertex.glsl +68 -0
  167. package/src/shaders/circle.vertex.glsl.g.ts +2 -0
  168. package/src/shaders/clipping_mask.fragment.glsl +3 -0
  169. package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
  170. package/src/shaders/clipping_mask.vertex.glsl +7 -0
  171. package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
  172. package/src/shaders/collision_box.fragment.glsl +20 -0
  173. package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
  174. package/src/shaders/collision_box.vertex.glsl +27 -0
  175. package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
  176. package/src/shaders/collision_circle.fragment.glsl +17 -0
  177. package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
  178. package/src/shaders/collision_circle.vertex.glsl +59 -0
  179. package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
  180. package/src/shaders/debug.fragment.glsl +9 -0
  181. package/src/shaders/debug.fragment.glsl.g.ts +2 -0
  182. package/src/shaders/debug.vertex.glsl +12 -0
  183. package/src/shaders/debug.vertex.glsl.g.ts +2 -0
  184. package/src/shaders/encode_attribute.test.ts +11 -0
  185. package/src/shaders/encode_attribute.ts +13 -0
  186. package/src/shaders/fill.fragment.glsl +13 -0
  187. package/src/shaders/fill.fragment.glsl.g.ts +2 -0
  188. package/src/shaders/fill.vertex.glsl +13 -0
  189. package/src/shaders/fill.vertex.glsl.g.ts +2 -0
  190. package/src/shaders/fill_extrusion.fragment.glsl +9 -0
  191. package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
  192. package/src/shaders/fill_extrusion.vertex.glsl +84 -0
  193. package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
  194. package/src/shaders/fill_extrusion_pattern.fragment.glsl +47 -0
  195. package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
  196. package/src/shaders/fill_extrusion_pattern.vertex.glsl +96 -0
  197. package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
  198. package/src/shaders/fill_outline.fragment.glsl +17 -0
  199. package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
  200. package/src/shaders/fill_outline.vertex.glsl +17 -0
  201. package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
  202. package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
  203. package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
  204. package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
  205. package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
  206. package/src/shaders/fill_pattern.fragment.glsl +39 -0
  207. package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
  208. package/src/shaders/fill_pattern.vertex.glsl +39 -0
  209. package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
  210. package/src/shaders/heatmap.fragment.glsl +22 -0
  211. package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
  212. package/src/shaders/heatmap.vertex.glsl +54 -0
  213. package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
  214. package/src/shaders/heatmap_texture.fragment.glsl +15 -0
  215. package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
  216. package/src/shaders/heatmap_texture.vertex.glsl +11 -0
  217. package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
  218. package/src/shaders/hillshade.fragment.glsl +52 -0
  219. package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
  220. package/src/shaders/hillshade.vertex.glsl +11 -0
  221. package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
  222. package/src/shaders/hillshade_prepare.fragment.glsl +77 -0
  223. package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
  224. package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
  225. package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
  226. package/src/shaders/line.fragment.glsl +30 -0
  227. package/src/shaders/line.fragment.glsl.g.ts +2 -0
  228. package/src/shaders/line.vertex.glsl +89 -0
  229. package/src/shaders/line.vertex.glsl.g.ts +2 -0
  230. package/src/shaders/line_gradient.fragment.glsl +34 -0
  231. package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
  232. package/src/shaders/line_gradient.vertex.glsl +92 -0
  233. package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
  234. package/src/shaders/line_pattern.fragment.glsl +77 -0
  235. package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
  236. package/src/shaders/line_pattern.vertex.glsl +103 -0
  237. package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
  238. package/src/shaders/line_sdf.fragment.glsl +45 -0
  239. package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
  240. package/src/shaders/line_sdf.vertex.glsl +101 -0
  241. package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
  242. package/src/shaders/raster.fragment.glsl +53 -0
  243. package/src/shaders/raster.fragment.glsl.g.ts +2 -0
  244. package/src/shaders/raster.vertex.glsl +21 -0
  245. package/src/shaders/raster.vertex.glsl.g.ts +2 -0
  246. package/src/shaders/shaders.ts +197 -0
  247. package/src/shaders/sky.fragment.glsl +17 -0
  248. package/src/shaders/sky.fragment.glsl.g.ts +2 -0
  249. package/src/shaders/sky.vertex.glsl +5 -0
  250. package/src/shaders/sky.vertex.glsl.g.ts +2 -0
  251. package/src/shaders/symbol_icon.fragment.glsl +17 -0
  252. package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
  253. package/src/shaders/symbol_icon.vertex.glsl +117 -0
  254. package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
  255. package/src/shaders/symbol_sdf.fragment.glsl +58 -0
  256. package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
  257. package/src/shaders/symbol_sdf.vertex.glsl +142 -0
  258. package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
  259. package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
  260. package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
  261. package/src/shaders/symbol_text_and_icon.vertex.glsl +140 -0
  262. package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
  263. package/src/shaders/terrain.fragment.glsl +32 -0
  264. package/src/shaders/terrain.fragment.glsl.g.ts +2 -0
  265. package/src/shaders/terrain.vertex.glsl +17 -0
  266. package/src/shaders/terrain.vertex.glsl.g.ts +2 -0
  267. package/src/shaders/terrain_coords.fragment.glsl +11 -0
  268. package/src/shaders/terrain_coords.fragment.glsl.g.ts +2 -0
  269. package/src/shaders/terrain_coords.vertex.glsl +13 -0
  270. package/src/shaders/terrain_coords.vertex.glsl.g.ts +2 -0
  271. package/src/shaders/terrain_depth.fragment.glsl +15 -0
  272. package/src/shaders/terrain_depth.fragment.glsl.g.ts +2 -0
  273. package/src/shaders/terrain_depth.vertex.glsl +13 -0
  274. package/src/shaders/terrain_depth.vertex.glsl.g.ts +2 -0
  275. package/src/source/canvas_source.test.ts +210 -0
  276. package/src/source/canvas_source.ts +227 -0
  277. package/src/source/geojson_source.test.ts +492 -0
  278. package/src/source/geojson_source.ts +431 -0
  279. package/src/source/geojson_source_diff.test.ts +364 -0
  280. package/src/source/geojson_source_diff.ts +172 -0
  281. package/src/source/geojson_worker_source.test.ts +399 -0
  282. package/src/source/geojson_worker_source.ts +303 -0
  283. package/src/source/geojson_wrapper.test.ts +32 -0
  284. package/src/source/geojson_wrapper.ts +81 -0
  285. package/src/source/image_source.test.ts +235 -0
  286. package/src/source/image_source.ts +338 -0
  287. package/src/source/load_tilejson.ts +47 -0
  288. package/src/source/pixels_to_tile_units.ts +25 -0
  289. package/src/source/protocol_crud.ts +48 -0
  290. package/src/source/query_features.test.ts +31 -0
  291. package/src/source/query_features.ts +252 -0
  292. package/src/source/raster_dem_tile_source.test.ts +158 -0
  293. package/src/source/raster_dem_tile_source.ts +166 -0
  294. package/src/source/raster_dem_tile_worker_source.test.ts +36 -0
  295. package/src/source/raster_dem_tile_worker_source.ts +38 -0
  296. package/src/source/raster_tile_source.test.ts +206 -0
  297. package/src/source/raster_tile_source.ts +227 -0
  298. package/src/source/rtl_text_plugin_main_thread.test.ts +170 -0
  299. package/src/source/rtl_text_plugin_main_thread.ts +89 -0
  300. package/src/source/rtl_text_plugin_status.ts +33 -0
  301. package/src/source/rtl_text_plugin_worker.ts +49 -0
  302. package/src/source/source.test.ts +41 -0
  303. package/src/source/source.ts +186 -0
  304. package/src/source/source_cache.test.ts +2069 -0
  305. package/src/source/source_cache.ts +1102 -0
  306. package/src/source/source_state.ts +157 -0
  307. package/src/source/terrain_source_cache.test.ts +105 -0
  308. package/src/source/terrain_source_cache.ts +204 -0
  309. package/src/source/tile.test.ts +290 -0
  310. package/src/source/tile.ts +478 -0
  311. package/src/source/tile_bounds.ts +34 -0
  312. package/src/source/tile_cache.test.ts +130 -0
  313. package/src/source/tile_cache.ts +208 -0
  314. package/src/source/tile_id.test.ts +112 -0
  315. package/src/source/tile_id.ts +221 -0
  316. package/src/source/vector_tile_source.test.ts +401 -0
  317. package/src/source/vector_tile_source.ts +283 -0
  318. package/src/source/vector_tile_worker_source.test.ts +396 -0
  319. package/src/source/vector_tile_worker_source.ts +199 -0
  320. package/src/source/video_source.test.ts +124 -0
  321. package/src/source/video_source.ts +204 -0
  322. package/src/source/worker.test.ts +233 -0
  323. package/src/source/worker.ts +301 -0
  324. package/src/source/worker_source.ts +117 -0
  325. package/src/source/worker_tile.test.ts +226 -0
  326. package/src/source/worker_tile.ts +208 -0
  327. package/src/style/create_style_layer.ts +39 -0
  328. package/src/style/evaluation_parameters.ts +62 -0
  329. package/src/style/format_section_override.test.ts +62 -0
  330. package/src/style/format_section_override.ts +50 -0
  331. package/src/style/light.test.ts +86 -0
  332. package/src/style/light.ts +135 -0
  333. package/src/style/load_glyph_range.test.ts +40 -0
  334. package/src/style/load_glyph_range.ts +32 -0
  335. package/src/style/load_sprite.test.ts +227 -0
  336. package/src/style/load_sprite.ts +71 -0
  337. package/src/style/parse_glyph_pbf.ts +42 -0
  338. package/src/style/pauseable_placement.ts +138 -0
  339. package/src/style/properties.ts +726 -0
  340. package/src/style/query_utils.test.ts +107 -0
  341. package/src/style/query_utils.ts +70 -0
  342. package/src/style/sky.ts +127 -0
  343. package/src/style/style.test.ts +2654 -0
  344. package/src/style/style.ts +1814 -0
  345. package/src/style/style_glyph.ts +25 -0
  346. package/src/style/style_image.ts +188 -0
  347. package/src/style/style_layer/background_style_layer.ts +17 -0
  348. package/src/style/style_layer/background_style_layer_properties.g.ts +40 -0
  349. package/src/style/style_layer/circle_style_layer.ts +98 -0
  350. package/src/style/style_layer/circle_style_layer_properties.g.ts +76 -0
  351. package/src/style/style_layer/custom_style_layer.ts +233 -0
  352. package/src/style/style_layer/fill_extrusion_style_layer.ts +224 -0
  353. package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +55 -0
  354. package/src/style/style_layer/fill_style_layer.test.ts +37 -0
  355. package/src/style/style_layer/fill_style_layer.ts +65 -0
  356. package/src/style/style_layer/fill_style_layer_properties.g.ts +64 -0
  357. package/src/style/style_layer/heatmap_style_layer.ts +74 -0
  358. package/src/style/style_layer/heatmap_style_layer_properties.g.ts +46 -0
  359. package/src/style/style_layer/hillshade_style_layer.ts +21 -0
  360. package/src/style/style_layer/hillshade_style_layer_properties.g.ts +49 -0
  361. package/src/style/style_layer/line_style_layer.test.ts +50 -0
  362. package/src/style/style_layer/line_style_layer.ts +131 -0
  363. package/src/style/style_layer/line_style_layer_properties.g.ts +88 -0
  364. package/src/style/style_layer/overlap_mode.test.ts +57 -0
  365. package/src/style/style_layer/overlap_mode.ts +25 -0
  366. package/src/style/style_layer/raster_style_layer.ts +17 -0
  367. package/src/style/style_layer/raster_style_layer_properties.g.ts +55 -0
  368. package/src/style/style_layer/symbol_style_layer.ts +195 -0
  369. package/src/style/style_layer/symbol_style_layer_properties.g.ts +218 -0
  370. package/src/style/style_layer/typed_style_layer.ts +9 -0
  371. package/src/style/style_layer/variable_text_anchor.test.ts +117 -0
  372. package/src/style/style_layer/variable_text_anchor.ts +163 -0
  373. package/src/style/style_layer.test.ts +372 -0
  374. package/src/style/style_layer.ts +287 -0
  375. package/src/style/style_layer_index.test.ts +99 -0
  376. package/src/style/style_layer_index.ts +78 -0
  377. package/src/style/validate_style.ts +53 -0
  378. package/src/style/zoom_history.ts +40 -0
  379. package/src/symbol/anchor.test.ts +14 -0
  380. package/src/symbol/anchor.ts +22 -0
  381. package/src/symbol/check_max_angle.test.ts +54 -0
  382. package/src/symbol/check_max_angle.ts +76 -0
  383. package/src/symbol/clip_line.test.ts +154 -0
  384. package/src/symbol/clip_line.ts +66 -0
  385. package/src/symbol/collision_feature.test.ts +98 -0
  386. package/src/symbol/collision_feature.ts +114 -0
  387. package/src/symbol/collision_index.test.ts +19 -0
  388. package/src/symbol/collision_index.ts +618 -0
  389. package/src/symbol/cross_tile_symbol_index.test.ts +260 -0
  390. package/src/symbol/cross_tile_symbol_index.ts +367 -0
  391. package/src/symbol/get_anchors.test.ts +113 -0
  392. package/src/symbol/get_anchors.ts +167 -0
  393. package/src/symbol/grid_index.test.ts +75 -0
  394. package/src/symbol/grid_index.ts +414 -0
  395. package/src/symbol/merge_lines.test.ts +30 -0
  396. package/src/symbol/merge_lines.ts +80 -0
  397. package/src/symbol/one_em.ts +3 -0
  398. package/src/symbol/opacity_state.ts +23 -0
  399. package/src/symbol/path_interpolator.test.ts +134 -0
  400. package/src/symbol/path_interpolator.ts +55 -0
  401. package/src/symbol/placement.ts +1371 -0
  402. package/src/symbol/projection.test.ts +171 -0
  403. package/src/symbol/projection.ts +833 -0
  404. package/src/symbol/quads.test.ts +157 -0
  405. package/src/symbol/quads.ts +349 -0
  406. package/src/symbol/shaping.test.ts +360 -0
  407. package/src/symbol/shaping.ts +911 -0
  408. package/src/symbol/symbol_layout.ts +739 -0
  409. package/src/symbol/symbol_size.ts +129 -0
  410. package/src/symbol/symbol_style_layer.test.ts +103 -0
  411. package/src/symbol/transform_text.ts +27 -0
  412. package/src/ui/anchor.ts +27 -0
  413. package/src/ui/camera.test.ts +2301 -0
  414. package/src/ui/camera.ts +1520 -0
  415. package/src/ui/control/attribution_control.test.ts +543 -0
  416. package/src/ui/control/attribution_control.ts +209 -0
  417. package/src/ui/control/control.ts +67 -0
  418. package/src/ui/control/fullscreen_control.test.ts +114 -0
  419. package/src/ui/control/fullscreen_control.ts +189 -0
  420. package/src/ui/control/geolocate_control.test.ts +619 -0
  421. package/src/ui/control/geolocate_control.ts +725 -0
  422. package/src/ui/control/logo_control.test.ts +88 -0
  423. package/src/ui/control/logo_control.ts +86 -0
  424. package/src/ui/control/navigation_control.test.ts +238 -0
  425. package/src/ui/control/navigation_control.ts +294 -0
  426. package/src/ui/control/scale_control.test.ts +52 -0
  427. package/src/ui/control/scale_control.ts +152 -0
  428. package/src/ui/control/terrain_control.test.ts +58 -0
  429. package/src/ui/control/terrain_control.ts +74 -0
  430. package/src/ui/default_locale.ts +25 -0
  431. package/src/ui/events.ts +758 -0
  432. package/src/ui/handler/box_zoom.test.ts +163 -0
  433. package/src/ui/handler/box_zoom.ts +171 -0
  434. package/src/ui/handler/click_zoom.ts +55 -0
  435. package/src/ui/handler/cooperative_gestures.test.ts +338 -0
  436. package/src/ui/handler/cooperative_gestures.ts +111 -0
  437. package/src/ui/handler/dblclick_zoom.test.ts +151 -0
  438. package/src/ui/handler/drag_handler.ts +174 -0
  439. package/src/ui/handler/drag_move_state_manager.ts +115 -0
  440. package/src/ui/handler/drag_pan.test.ts +487 -0
  441. package/src/ui/handler/drag_rotate.test.ts +859 -0
  442. package/src/ui/handler/handler_util.ts +10 -0
  443. package/src/ui/handler/keyboard.test.ts +235 -0
  444. package/src/ui/handler/keyboard.ts +212 -0
  445. package/src/ui/handler/map_event.test.ts +158 -0
  446. package/src/ui/handler/map_event.ts +161 -0
  447. package/src/ui/handler/mouse.ts +92 -0
  448. package/src/ui/handler/mouse_handler_interface.test.ts +111 -0
  449. package/src/ui/handler/mouse_rotate.test.ts +62 -0
  450. package/src/ui/handler/one_finger_touch_drag.ts +45 -0
  451. package/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts +77 -0
  452. package/src/ui/handler/scroll_zoom.test.ts +382 -0
  453. package/src/ui/handler/scroll_zoom.ts +379 -0
  454. package/src/ui/handler/shim/dblclick_zoom.ts +64 -0
  455. package/src/ui/handler/shim/drag_pan.ts +104 -0
  456. package/src/ui/handler/shim/drag_rotate.ts +76 -0
  457. package/src/ui/handler/shim/two_fingers_touch.ts +112 -0
  458. package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
  459. package/src/ui/handler/tap_drag_zoom.ts +112 -0
  460. package/src/ui/handler/tap_recognizer.ts +138 -0
  461. package/src/ui/handler/tap_zoom.ts +98 -0
  462. package/src/ui/handler/touch_pan.ts +115 -0
  463. package/src/ui/handler/transform-provider.ts +44 -0
  464. package/src/ui/handler/two_fingers_touch.test.ts +283 -0
  465. package/src/ui/handler/two_fingers_touch.ts +336 -0
  466. package/src/ui/handler_inertia.ts +157 -0
  467. package/src/ui/handler_manager.ts +637 -0
  468. package/src/ui/hash.test.ts +404 -0
  469. package/src/ui/hash.ts +153 -0
  470. package/src/ui/map.ts +3393 -0
  471. package/src/ui/map_tests/map_animation.test.ts +61 -0
  472. package/src/ui/map_tests/map_basic.test.ts +223 -0
  473. package/src/ui/map_tests/map_bounds.test.ts +123 -0
  474. package/src/ui/map_tests/map_calculate_camera_options.test.ts +113 -0
  475. package/src/ui/map_tests/map_canvas.test.ts +59 -0
  476. package/src/ui/map_tests/map_control.test.ts +61 -0
  477. package/src/ui/map_tests/map_disable_handlers.test.ts +38 -0
  478. package/src/ui/map_tests/map_events.test.ts +1001 -0
  479. package/src/ui/map_tests/map_feature_state.test.ts +421 -0
  480. package/src/ui/map_tests/map_images.test.ts +175 -0
  481. package/src/ui/map_tests/map_is_moving.test.ts +164 -0
  482. package/src/ui/map_tests/map_is_rotating.test.ts +62 -0
  483. package/src/ui/map_tests/map_is_zooming.test.ts +86 -0
  484. package/src/ui/map_tests/map_layer.test.ts +457 -0
  485. package/src/ui/map_tests/map_options.test.ts +64 -0
  486. package/src/ui/map_tests/map_pitch.test.ts +90 -0
  487. package/src/ui/map_tests/map_pixel_ratio.test.ts +75 -0
  488. package/src/ui/map_tests/map_query_rendered_features.test.ts +93 -0
  489. package/src/ui/map_tests/map_render.test.ts +90 -0
  490. package/src/ui/map_tests/map_request_render_frame.test.ts +51 -0
  491. package/src/ui/map_tests/map_resize.test.ts +120 -0
  492. package/src/ui/map_tests/map_style.test.ts +541 -0
  493. package/src/ui/map_tests/map_terrian.test.ts +104 -0
  494. package/src/ui/map_tests/map_webgl.test.ts +72 -0
  495. package/src/ui/map_tests/map_world_copies.test.ts +103 -0
  496. package/src/ui/map_tests/map_zoom.test.ts +95 -0
  497. package/src/ui/marker.test.ts +1149 -0
  498. package/src/ui/marker.ts +880 -0
  499. package/src/ui/popup.test.ts +827 -0
  500. package/src/ui/popup.ts +717 -0
  501. package/src/util/abort_error.ts +21 -0
  502. package/src/util/actor.test.ts +218 -0
  503. package/src/util/actor.ts +241 -0
  504. package/src/util/actor_messages.ts +149 -0
  505. package/src/util/ajax.test.ts +237 -0
  506. package/src/util/ajax.ts +297 -0
  507. package/src/util/browser.test.ts +23 -0
  508. package/src/util/browser.ts +63 -0
  509. package/src/util/color_ramp.test.ts +105 -0
  510. package/src/util/color_ramp.ts +56 -0
  511. package/src/util/config.ts +29 -0
  512. package/src/util/dictionary_coder.ts +23 -0
  513. package/src/util/dispatcher.test.ts +76 -0
  514. package/src/util/dispatcher.ts +78 -0
  515. package/src/util/dom.ts +135 -0
  516. package/src/util/evented.test.ts +231 -0
  517. package/src/util/evented.ts +178 -0
  518. package/src/util/find_pole_of_inaccessibility.test.ts +21 -0
  519. package/src/util/find_pole_of_inaccessibility.ts +130 -0
  520. package/src/util/geolocation_support.test.ts +43 -0
  521. package/src/util/geolocation_support.ts +23 -0
  522. package/src/util/global_worker_pool.ts +65 -0
  523. package/src/util/image.ts +150 -0
  524. package/src/util/image_request.test.ts +408 -0
  525. package/src/util/image_request.ts +246 -0
  526. package/src/util/intersection_tests.ts +206 -0
  527. package/src/util/is_char_in_unicode_block.test.ts +15 -0
  528. package/src/util/is_char_in_unicode_block.ts +345 -0
  529. package/src/util/offscreen_canvas_distorted.test.ts +13 -0
  530. package/src/util/offscreen_canvas_distorted.ts +39 -0
  531. package/src/util/offscreen_canvas_supported.ts +11 -0
  532. package/src/util/performance.ts +117 -0
  533. package/src/util/primitives.test.ts +140 -0
  534. package/src/util/primitives.ts +143 -0
  535. package/src/util/request_manager.ts +42 -0
  536. package/src/util/resolve_tokens.test.ts +45 -0
  537. package/src/util/resolve_tokens.ts +17 -0
  538. package/src/util/script_detection.test.ts +138 -0
  539. package/src/util/script_detection.ts +376 -0
  540. package/src/util/smart_wrap.test.ts +97 -0
  541. package/src/util/smart_wrap.ts +58 -0
  542. package/src/util/struct_array.test.ts +101 -0
  543. package/src/util/struct_array.ts +246 -0
  544. package/src/util/style.test.ts +34 -0
  545. package/src/util/style.ts +28 -0
  546. package/src/util/task_queue.test.ts +114 -0
  547. package/src/util/task_queue.ts +64 -0
  548. package/src/util/test/util.ts +185 -0
  549. package/src/util/throttle.test.ts +42 -0
  550. package/src/util/throttle.ts +28 -0
  551. package/src/util/throttled_invoker.ts +41 -0
  552. package/src/util/transferable_grid_index.test.ts +56 -0
  553. package/src/util/transferable_grid_index.ts +214 -0
  554. package/src/util/util.test.ts +414 -0
  555. package/src/util/util.ts +724 -0
  556. package/src/util/vectortile_to_geojson.ts +72 -0
  557. package/src/util/verticalize_punctuation.ts +110 -0
  558. package/src/util/web_worker.ts +16 -0
  559. package/src/util/web_worker_transfer.test.ts +153 -0
  560. package/src/util/web_worker_transfer.ts +254 -0
  561. package/src/util/webp_supported.ts +63 -0
  562. package/src/util/worker_pool.test.ts +43 -0
  563. package/src/util/worker_pool.ts +58 -0
  564. package/src/util/world_bounds.test.ts +59 -0
  565. package/src/util/world_bounds.ts +46 -0
@@ -0,0 +1,880 @@
1
+ import {DOM} from '../util/dom';
2
+ import {browser} from '../util/browser';
3
+ import {LngLat} from '../geo/lng_lat';
4
+ import Point from '@mapbox/point-geometry';
5
+ import {smartWrap} from '../util/smart_wrap';
6
+ import {anchorTranslate, applyAnchorClass} from './anchor';
7
+ import type {PositionAnchor} from './anchor';
8
+ import {Event, Evented} from '../util/evented';
9
+ import type {Map} from './map';
10
+ import {Popup, Offset} from './popup';
11
+ import type {LngLatLike} from '../geo/lng_lat';
12
+ import type {MapMouseEvent, MapTouchEvent} from './events';
13
+ import type {PointLike} from './camera';
14
+
15
+ /**
16
+ * Alignment options of rotation and pitch
17
+ */
18
+ type Alignment = 'map' | 'viewport' | 'auto';
19
+
20
+ /**
21
+ * The {@link Marker} options object
22
+ */
23
+ type MarkerOptions = {
24
+ /**
25
+ * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.
26
+ */
27
+ element?: HTMLElement;
28
+ /**
29
+ * Space-separated CSS class names to add to marker element.
30
+ */
31
+ className?: string;
32
+ /**
33
+ * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
34
+ */
35
+ offset?: PointLike;
36
+ /**
37
+ * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.
38
+ * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.
39
+ * @defaultValue 'center'
40
+ * */
41
+ anchor?: PositionAnchor;
42
+ /**
43
+ * The color to use for the default marker if options.element is not provided. The default is light blue.
44
+ * @defaultValue '#3FB1CE'
45
+ */
46
+ color?: string;
47
+ /**
48
+ * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.
49
+ * @defaultValue 1
50
+ */
51
+ scale?: number;
52
+ /**
53
+ * A boolean indicating whether or not a marker is able to be dragged to a new position on the map.
54
+ * @defaultValue false
55
+ */
56
+ draggable?: boolean;
57
+ /**
58
+ * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.
59
+ * @defaultValue 0
60
+ */
61
+ clickTolerance?: number;
62
+ /**
63
+ * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.
64
+ * @defaultValue 0
65
+ */
66
+ rotation?: number;
67
+ /**
68
+ * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.
69
+ * @defaultValue 'auto'
70
+ */
71
+ rotationAlignment?: Alignment;
72
+ /**
73
+ * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.
74
+ * @defaultValue 'auto'
75
+ */
76
+ pitchAlignment?: Alignment;
77
+ /**
78
+ * Marker's opacity when it's in clear view (not behind 3d terrain)
79
+ * @defaultValue 1
80
+ */
81
+ opacity?: string;
82
+ /**
83
+ * Marker's opacity when it's behind 3d terrain
84
+ * @defaultValue 0.2
85
+ */
86
+ opacityWhenCovered?: string;
87
+ /**
88
+ * If `true`, rounding is disabled for placement of the marker, allowing for
89
+ * subpixel positioning and smoother movement when the marker is translated.
90
+ * @defaultValue false
91
+ */
92
+ subpixelPositioning?: boolean;
93
+ };
94
+
95
+ /**
96
+ * Creates a marker component
97
+ *
98
+ * @group Markers and Controls
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * let marker = new Marker()
103
+ * .setLngLat([30.5, 50.5])
104
+ * .addTo(map);
105
+ * ```
106
+ *
107
+ * @example
108
+ * Set options
109
+ * ```ts
110
+ * let marker = new Marker({
111
+ * color: "#FFFFFF",
112
+ * draggable: true
113
+ * }).setLngLat([30.5, 50.5])
114
+ * .addTo(map);
115
+ * ```
116
+ * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)
117
+ * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
118
+ *
119
+ * ## Events
120
+ *
121
+ * **Event** `dragstart` of type {@link Event} will be fired when dragging starts.
122
+ *
123
+ * **Event** `drag` of type {@link Event} will be fired while dragging.
124
+ *
125
+ * **Event** `dragend` of type {@link Event} will be fired when the marker is finished being dragged.
126
+ */
127
+ export class Marker extends Evented {
128
+ _map: Map;
129
+ _anchor: PositionAnchor;
130
+ _offset: Point;
131
+ _element: HTMLElement;
132
+ _popup: Popup;
133
+ _lngLat: LngLat;
134
+ _pos: Point;
135
+ _flatPos: Point;
136
+ _color: string;
137
+ _scale: number;
138
+ _defaultMarker: boolean;
139
+ _draggable: boolean;
140
+ _clickTolerance: number;
141
+ _isDragging: boolean;
142
+ _state: 'inactive' | 'pending' | 'active'; // used for handling drag events
143
+ _positionDelta: Point;
144
+ _pointerdownPos: Point;
145
+ _rotation: number;
146
+ _pitchAlignment: Alignment;
147
+ _rotationAlignment: Alignment;
148
+ _originalTabIndex: string; // original tabindex of _element
149
+ _opacity: string;
150
+ _opacityWhenCovered: string;
151
+ _opacityTimeout: ReturnType<typeof setTimeout>;
152
+ _subpixelPositioning: boolean;
153
+
154
+ /**
155
+ * @param options - the options
156
+ */
157
+ constructor(options?: MarkerOptions) {
158
+ super();
159
+
160
+ this._anchor = options && options.anchor || 'center';
161
+ this._color = options && options.color || '#3FB1CE';
162
+ this._scale = options && options.scale || 1;
163
+ this._draggable = options && options.draggable || false;
164
+ this._clickTolerance = options && options.clickTolerance || 0;
165
+ this._subpixelPositioning = options && options.subpixelPositioning || false;
166
+ this._isDragging = false;
167
+ this._state = 'inactive';
168
+ this._rotation = options && options.rotation || 0;
169
+ this._rotationAlignment = options && options.rotationAlignment || 'auto';
170
+ this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment;
171
+ this.setOpacity(); // set default opacity
172
+ this.setOpacity(options?.opacity, options?.opacityWhenCovered);
173
+
174
+ if (!options || !options.element) {
175
+ this._defaultMarker = true;
176
+ this._element = DOM.create('div');
177
+
178
+ // create default map marker SVG
179
+ const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg');
180
+ const defaultHeight = 41;
181
+ const defaultWidth = 27;
182
+ svg.setAttributeNS(null, 'display', 'block');
183
+ svg.setAttributeNS(null, 'height', `${defaultHeight}px`);
184
+ svg.setAttributeNS(null, 'width', `${defaultWidth}px`);
185
+ svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`);
186
+
187
+ const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g');
188
+ markerLarge.setAttributeNS(null, 'stroke', 'none');
189
+ markerLarge.setAttributeNS(null, 'stroke-width', '1');
190
+ markerLarge.setAttributeNS(null, 'fill', 'none');
191
+ markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd');
192
+
193
+ const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g');
194
+ page1.setAttributeNS(null, 'fill-rule', 'nonzero');
195
+
196
+ const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g');
197
+ shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)');
198
+ shadow.setAttributeNS(null, 'fill', '#000000');
199
+
200
+ const ellipses = [
201
+ {'rx': '10.5', 'ry': '5.25002273'},
202
+ {'rx': '10.5', 'ry': '5.25002273'},
203
+ {'rx': '9.5', 'ry': '4.77275007'},
204
+ {'rx': '8.5', 'ry': '4.29549936'},
205
+ {'rx': '7.5', 'ry': '3.81822308'},
206
+ {'rx': '6.5', 'ry': '3.34094679'},
207
+ {'rx': '5.5', 'ry': '2.86367051'},
208
+ {'rx': '4.5', 'ry': '2.38636864'}
209
+ ];
210
+
211
+ for (const data of ellipses) {
212
+ const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse');
213
+ ellipse.setAttributeNS(null, 'opacity', '0.04');
214
+ ellipse.setAttributeNS(null, 'cx', '10.5');
215
+ ellipse.setAttributeNS(null, 'cy', '5.80029008');
216
+ ellipse.setAttributeNS(null, 'rx', data['rx']);
217
+ ellipse.setAttributeNS(null, 'ry', data['ry']);
218
+ shadow.appendChild(ellipse);
219
+ }
220
+
221
+ const background = DOM.createNS('http://www.w3.org/2000/svg', 'g');
222
+ background.setAttributeNS(null, 'fill', this._color);
223
+
224
+ const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');
225
+ bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z');
226
+
227
+ background.appendChild(bgPath);
228
+
229
+ const border = DOM.createNS('http://www.w3.org/2000/svg', 'g');
230
+ border.setAttributeNS(null, 'opacity', '0.25');
231
+ border.setAttributeNS(null, 'fill', '#000000');
232
+
233
+ const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');
234
+ borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z');
235
+
236
+ border.appendChild(borderPath);
237
+
238
+ const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g');
239
+ maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)');
240
+ maki.setAttributeNS(null, 'fill', '#FFFFFF');
241
+
242
+ const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g');
243
+ circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)');
244
+
245
+ const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');
246
+ circle1.setAttributeNS(null, 'fill', '#000000');
247
+ circle1.setAttributeNS(null, 'opacity', '0.25');
248
+ circle1.setAttributeNS(null, 'cx', '5.5');
249
+ circle1.setAttributeNS(null, 'cy', '5.5');
250
+ circle1.setAttributeNS(null, 'r', '5.4999962');
251
+
252
+ const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');
253
+ circle2.setAttributeNS(null, 'fill', '#FFFFFF');
254
+ circle2.setAttributeNS(null, 'cx', '5.5');
255
+ circle2.setAttributeNS(null, 'cy', '5.5');
256
+ circle2.setAttributeNS(null, 'r', '5.4999962');
257
+
258
+ circleContainer.appendChild(circle1);
259
+ circleContainer.appendChild(circle2);
260
+
261
+ page1.appendChild(shadow);
262
+ page1.appendChild(background);
263
+ page1.appendChild(border);
264
+ page1.appendChild(maki);
265
+ page1.appendChild(circleContainer);
266
+
267
+ svg.appendChild(page1);
268
+
269
+ svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`);
270
+ svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`);
271
+
272
+ this._element.appendChild(svg);
273
+
274
+ // if no element and no offset option given apply an offset for the default marker
275
+ // the -14 as the y value of the default marker offset was determined as follows
276
+ //
277
+ // the marker tip is at the center of the shadow ellipse from the default svg
278
+ // the y value of the center of the shadow ellipse relative to the svg top left is "shadow transform translate-y (29.0) + ellipse cy (5.80029008)"
279
+ // offset to the svg center "height (41 / 2)" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14
280
+ // negative is used to move the marker up from the center so the tip is at the Marker lngLat
281
+ this._offset = Point.convert(options && options.offset || [0, -14]);
282
+ } else {
283
+ this._element = options.element;
284
+ this._offset = Point.convert(options && options.offset || [0, 0]);
285
+ }
286
+
287
+ this._element.classList.add('maplibregl-marker');
288
+ // Marker position is a raw pixel `translate()` written directly onto
289
+ // this element (see _update() below) — that math assumes an LTR
290
+ // coordinate space. If the element inherits `direction: rtl` from
291
+ // an ancestor (e.g. an Arabic-language page with dir="rtl" on
292
+ // <html>), the browser reinterprets the transform and the marker
293
+ // renders mirrored/off-position. Pin it to ltr so marker placement
294
+ // is correct regardless of the surrounding page's text direction.
295
+ // — Scoova fix, upstream MapLibre GL JS v4.7.1 base.
296
+ this._element.style.direction = 'ltr';
297
+ this._element.addEventListener('dragstart', (e: DragEvent) => {
298
+ e.preventDefault();
299
+ });
300
+ this._element.addEventListener('mousedown', (e: MouseEvent) => {
301
+ // prevent focusing on click
302
+ e.preventDefault();
303
+ });
304
+ applyAnchorClass(this._element, this._anchor, 'marker');
305
+
306
+ if (options && options.className) {
307
+ for (const name of options.className.split(' ')) {
308
+ this._element.classList.add(name);
309
+ }
310
+ }
311
+
312
+ this._popup = null;
313
+ }
314
+
315
+ /**
316
+ * Attaches the `Marker` to a `Map` object.
317
+ * @param map - The MapLibre GL JS map to add the marker to.
318
+ * @example
319
+ * ```ts
320
+ * let marker = new Marker()
321
+ * .setLngLat([30.5, 50.5])
322
+ * .addTo(map); // add the marker to the map
323
+ * ```
324
+ */
325
+ addTo(map: Map): this {
326
+ this.remove();
327
+ this._map = map;
328
+ this._element.setAttribute('aria-label', map._getUIString('Marker.Title'));
329
+
330
+ map.getCanvasContainer().appendChild(this._element);
331
+ map.on('move', this._update);
332
+ map.on('moveend', this._update);
333
+ map.on('terrain', this._update);
334
+
335
+ this.setDraggable(this._draggable);
336
+ this._update();
337
+
338
+ // If we attached the `click` listener to the marker element, the popup
339
+ // would close once the event propagated to `map` due to the
340
+ // `Popup#_onClickClose` listener.
341
+ this._map.on('click', this._onMapClick);
342
+
343
+ return this;
344
+ }
345
+
346
+ /**
347
+ * Removes the marker from a map
348
+ * @example
349
+ * ```ts
350
+ * let marker = new Marker().addTo(map);
351
+ * marker.remove();
352
+ * ```
353
+ */
354
+ remove(): this {
355
+ if (this._opacityTimeout) {
356
+ clearTimeout(this._opacityTimeout);
357
+ delete this._opacityTimeout;
358
+ }
359
+ if (this._map) {
360
+ this._map.off('click', this._onMapClick);
361
+ this._map.off('move', this._update);
362
+ this._map.off('moveend', this._update);
363
+ this._map.off('terrain', this._update);
364
+ this._map.off('mousedown', this._addDragHandler);
365
+ this._map.off('touchstart', this._addDragHandler);
366
+ this._map.off('mouseup', this._onUp);
367
+ this._map.off('touchend', this._onUp);
368
+ this._map.off('mousemove', this._onMove);
369
+ this._map.off('touchmove', this._onMove);
370
+ delete this._map;
371
+ }
372
+ DOM.remove(this._element);
373
+ if (this._popup) this._popup.remove();
374
+ return this;
375
+ }
376
+
377
+ /**
378
+ * Get the marker's geographical location.
379
+ *
380
+ * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously
381
+ * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep
382
+ * the marker on screen.
383
+ *
384
+ * @returns A {@link LngLat} describing the marker's location.
385
+ * @example
386
+ * ```ts
387
+ * // Store the marker's longitude and latitude coordinates in a variable
388
+ * let lngLat = marker.getLngLat();
389
+ * // Print the marker's longitude and latitude values in the console
390
+ * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )
391
+ * ```
392
+ * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
393
+ */
394
+ getLngLat(): LngLat {
395
+ return this._lngLat;
396
+ }
397
+
398
+ /**
399
+ * Set the marker's geographical position and move it.
400
+ * @param lnglat - A {@link LngLat} describing where the marker should be located.
401
+ * @example
402
+ * Create a new marker, set the longitude and latitude, and add it to the map
403
+ * ```ts
404
+ * new Marker()
405
+ * .setLngLat([-65.017, -16.457])
406
+ * .addTo(map);
407
+ * ```
408
+ * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)
409
+ * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
410
+ */
411
+ setLngLat(lnglat: LngLatLike): this {
412
+ this._lngLat = LngLat.convert(lnglat);
413
+ this._pos = null;
414
+ if (this._popup) this._popup.setLngLat(this._lngLat);
415
+ this._update();
416
+ return this;
417
+ }
418
+
419
+ /**
420
+ * Returns the `Marker`'s HTML element.
421
+ * @returns element
422
+ */
423
+ getElement(): HTMLElement {
424
+ return this._element;
425
+ }
426
+
427
+ /**
428
+ * Binds a {@link Popup} to the {@link Marker}.
429
+ * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup
430
+ * set on this {@link Marker} instance is unset.
431
+ * @example
432
+ * ```ts
433
+ * let marker = new Marker()
434
+ * .setLngLat([0, 0])
435
+ * .setPopup(new Popup().setHTML("<h1>Hello World!</h1>")) // add popup
436
+ * .addTo(map);
437
+ * ```
438
+ * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)
439
+ */
440
+ setPopup(popup?: Popup | null): this {
441
+ if (this._popup) {
442
+ this._popup.remove();
443
+ this._popup = null;
444
+ this._element.removeEventListener('keypress', this._onKeyPress);
445
+
446
+ if (!this._originalTabIndex) {
447
+ this._element.removeAttribute('tabindex');
448
+ }
449
+ }
450
+
451
+ if (popup) {
452
+ if (!('offset' in popup.options)) {
453
+ const markerHeight = 41 - (5.8 / 2);
454
+ const markerRadius = 13.5;
455
+ const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
456
+ popup.options.offset = this._defaultMarker ? {
457
+ 'top': [0, 0],
458
+ 'top-left': [0, 0],
459
+ 'top-right': [0, 0],
460
+ 'bottom': [0, -markerHeight],
461
+ 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
462
+ 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
463
+ 'left': [markerRadius, (markerHeight - markerRadius) * -1],
464
+ 'right': [-markerRadius, (markerHeight - markerRadius) * -1]
465
+ } as Offset : this._offset;
466
+ }
467
+ this._popup = popup;
468
+
469
+ this._originalTabIndex = this._element.getAttribute('tabindex');
470
+ if (!this._originalTabIndex) {
471
+ this._element.setAttribute('tabindex', '0');
472
+ }
473
+ this._element.addEventListener('keypress', this._onKeyPress);
474
+ }
475
+
476
+ return this;
477
+ }
478
+
479
+ /**
480
+ * Set the option to allow subpixel positioning of the marker by passing a boolean
481
+ *
482
+ * @param value - when set to `true`, subpixel positioning is enabled for the marker.
483
+ *
484
+ * @example
485
+ * ```ts
486
+ * let marker = new Marker()
487
+ * marker.setSubpixelPositioning(true);
488
+ * ```
489
+ */
490
+ setSubpixelPositioning(value: boolean) {
491
+ this._subpixelPositioning = value;
492
+ return this;
493
+ }
494
+
495
+ _onKeyPress = (e: KeyboardEvent) => {
496
+ const code = e.code;
497
+ const legacyCode = e.charCode || e.keyCode;
498
+
499
+ if (
500
+ (code === 'Space') || (code === 'Enter') ||
501
+ (legacyCode === 32) || (legacyCode === 13) // space or enter
502
+ ) {
503
+ this.togglePopup();
504
+ }
505
+ };
506
+
507
+ _onMapClick = (e: MapMouseEvent) => {
508
+ const targetElement = e.originalEvent.target;
509
+ const element = this._element;
510
+
511
+ if (this._popup && (targetElement === element || element.contains(targetElement as any))) {
512
+ this.togglePopup();
513
+ }
514
+ };
515
+
516
+ /**
517
+ * Returns the {@link Popup} instance that is bound to the {@link Marker}.
518
+ * @returns popup
519
+ * @example
520
+ * ```ts
521
+ * let marker = new Marker()
522
+ * .setLngLat([0, 0])
523
+ * .setPopup(new Popup().setHTML("<h1>Hello World!</h1>"))
524
+ * .addTo(map);
525
+ *
526
+ * console.log(marker.getPopup()); // return the popup instance
527
+ * ```
528
+ */
529
+ getPopup(): Popup {
530
+ return this._popup;
531
+ }
532
+
533
+ /**
534
+ * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}.
535
+ * @example
536
+ * ```ts
537
+ * let marker = new Marker()
538
+ * .setLngLat([0, 0])
539
+ * .setPopup(new Popup().setHTML("<h1>Hello World!</h1>"))
540
+ * .addTo(map);
541
+ *
542
+ * marker.togglePopup(); // toggle popup open or closed
543
+ * ```
544
+ */
545
+ togglePopup(): this {
546
+ const popup = this._popup;
547
+
548
+ if (this._element.style.opacity === this._opacityWhenCovered) return this;
549
+
550
+ if (!popup) return this;
551
+ else if (popup.isOpen()) popup.remove();
552
+ else {
553
+ popup.setLngLat(this._lngLat);
554
+ popup.addTo(this._map);
555
+ }
556
+ return this;
557
+ }
558
+
559
+ _updateOpacity(force: boolean = false) {
560
+ const terrain = this._map?.terrain;
561
+ if (!terrain) {
562
+ if (this._element.style.opacity !== this._opacity) { this._element.style.opacity = this._opacity; }
563
+ return;
564
+ }
565
+ if (force) {
566
+ this._opacityTimeout = null;
567
+ } else {
568
+ if (this._opacityTimeout) { return; }
569
+ this._opacityTimeout = setTimeout(() => {
570
+ this._opacityTimeout = null;
571
+ }, 100);
572
+ }
573
+
574
+ const map = this._map;
575
+
576
+ // Read depth framebuffer, getting position of terrain in line of sight to marker
577
+ const terrainDistance = map.terrain.depthAtPoint(this._pos);
578
+ // Transform marker position to clip space
579
+ const elevation = map.terrain.getElevationForLngLatZoom(this._lngLat, map.transform.tileZoom);
580
+ const markerDistance = map.transform.lngLatToCameraDepth(this._lngLat, elevation);
581
+
582
+ const forgiveness = .006;
583
+ if (markerDistance - terrainDistance < forgiveness) {
584
+ this._element.style.opacity = this._opacity;
585
+ return;
586
+ }
587
+ // If the base is obscured, use the offset to check if the marker's center is obscured.
588
+ const metersToCenter = -this._offset.y / map.transform._pixelPerMeter;
589
+ const elevationToCenter = Math.sin(map.getPitch() * Math.PI / 180) * metersToCenter;
590
+ const terrainDistanceCenter = map.terrain.depthAtPoint(new Point(this._pos.x, this._pos.y - this._offset.y));
591
+ const markerDistanceCenter = map.transform.lngLatToCameraDepth(this._lngLat, elevation + elevationToCenter);
592
+ // Display at full opacity if center is visible.
593
+ const centerIsInvisible = markerDistanceCenter - terrainDistanceCenter > forgiveness;
594
+
595
+ if (this._popup?.isOpen() && centerIsInvisible) this._popup.remove();
596
+ this._element.style.opacity = centerIsInvisible ? this._opacityWhenCovered : this._opacity;
597
+ }
598
+
599
+ _update = (e?: { type: 'move' | 'moveend' | 'terrain' | 'render' }) => {
600
+ if (!this._map) return;
601
+
602
+ const isFullyLoaded = this._map.loaded() && !this._map.isMoving();
603
+ if (e?.type === 'terrain' || (e?.type === 'render' && !isFullyLoaded)) {
604
+ this._map.once('render', this._update);
605
+ }
606
+
607
+ if (this._map.transform.renderWorldCopies) {
608
+ this._lngLat = smartWrap(this._lngLat, this._flatPos, this._map.transform);
609
+ } else {
610
+ this._lngLat = this._lngLat?.wrap();
611
+ }
612
+
613
+ this._flatPos = this._pos = this._map.project(this._lngLat)._add(this._offset);
614
+ if (this._map.terrain) {
615
+ // flat position is saved because smartWrap needs non-elevated points
616
+ this._flatPos = this._map.transform.locationPoint(this._lngLat)._add(this._offset);
617
+ }
618
+
619
+ let rotation = '';
620
+ if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') {
621
+ rotation = `rotateZ(${this._rotation}deg)`;
622
+ } else if (this._rotationAlignment === 'map') {
623
+ rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`;
624
+ }
625
+
626
+ let pitch = '';
627
+ if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') {
628
+ pitch = 'rotateX(0deg)';
629
+ } else if (this._pitchAlignment === 'map') {
630
+ pitch = `rotateX(${this._map.getPitch()}deg)`;
631
+ }
632
+
633
+ // because rounding the coordinates at every `move` event causes stuttered zooming
634
+ // we only round them when _update is called with `moveend` or when its called with
635
+ // no arguments (when the Marker is initialized or Marker#setLngLat is invoked).
636
+ if (!this._subpixelPositioning && (!e || e.type === 'moveend')) {
637
+ this._pos = this._pos.round();
638
+ }
639
+
640
+ DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);
641
+
642
+ browser.frameAsync(new AbortController()).then(() => { // Run _updateOpacity only after painter.render and drawDepth
643
+ this._updateOpacity(e && e.type === 'moveend');
644
+ }).catch(() => {});
645
+ };
646
+
647
+ /**
648
+ * Get the marker's offset.
649
+ * @returns The marker's screen coordinates in pixels.
650
+ */
651
+ getOffset(): Point {
652
+ return this._offset;
653
+ }
654
+
655
+ /**
656
+ * Sets the offset of the marker
657
+ * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
658
+ */
659
+ setOffset(offset: PointLike): this {
660
+ this._offset = Point.convert(offset);
661
+ this._update();
662
+ return this;
663
+ }
664
+
665
+ /**
666
+ * Adds a CSS class to the marker element.
667
+ *
668
+ * @param className - on-empty string with CSS class name to add to marker element
669
+ *
670
+ * @example
671
+ * ```
672
+ * let marker = new Marker()
673
+ * marker.addClassName('some-class')
674
+ * ```
675
+ */
676
+ addClassName(className: string) {
677
+ this._element.classList.add(className);
678
+ }
679
+
680
+ /**
681
+ * Removes a CSS class from the marker element.
682
+ *
683
+ * @param className - Non-empty string with CSS class name to remove from marker element
684
+ *
685
+ * @example
686
+ * ```ts
687
+ * let marker = new Marker()
688
+ * marker.removeClassName('some-class')
689
+ * ```
690
+ */
691
+ removeClassName(className: string) {
692
+ this._element.classList.remove(className);
693
+ }
694
+
695
+ /**
696
+ * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class.
697
+ *
698
+ * @param className - Non-empty string with CSS class name to add/remove
699
+ *
700
+ * @returns if the class was removed return false, if class was added, then return true
701
+ *
702
+ * @example
703
+ * ```ts
704
+ * let marker = new Marker()
705
+ * marker.toggleClassName('toggleClass')
706
+ * ```
707
+ */
708
+ toggleClassName(className: string): boolean {
709
+ return this._element.classList.toggle(className);
710
+ }
711
+
712
+ _onMove = (e: MapMouseEvent | MapTouchEvent) => {
713
+ if (!this._isDragging) {
714
+ const clickTolerance = this._clickTolerance || this._map._clickTolerance;
715
+ this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance;
716
+ }
717
+ if (!this._isDragging) return;
718
+
719
+ this._pos = e.point.sub(this._positionDelta);
720
+ this._lngLat = this._map.unproject(this._pos);
721
+ this.setLngLat(this._lngLat);
722
+ // suppress click event so that popups don't toggle on drag
723
+ this._element.style.pointerEvents = 'none';
724
+
725
+ // make sure dragstart only fires on the first move event after mousedown.
726
+ // this can't be on mousedown because that event doesn't necessarily
727
+ // imply that a drag is about to happen.
728
+ if (this._state === 'pending') {
729
+ this._state = 'active';
730
+ this.fire(new Event('dragstart'));
731
+ }
732
+ this.fire(new Event('drag'));
733
+ };
734
+
735
+ _onUp = () => {
736
+ // revert to normal pointer event handling
737
+ this._element.style.pointerEvents = 'auto';
738
+ this._positionDelta = null;
739
+ this._pointerdownPos = null;
740
+ this._isDragging = false;
741
+ this._map.off('mousemove', this._onMove);
742
+ this._map.off('touchmove', this._onMove);
743
+
744
+ // only fire dragend if it was preceded by at least one drag event
745
+ if (this._state === 'active') {
746
+ this.fire(new Event('dragend'));
747
+ }
748
+
749
+ this._state = 'inactive';
750
+ };
751
+
752
+ _addDragHandler = (e: MapMouseEvent | MapTouchEvent) => {
753
+ if (this._element.contains(e.originalEvent.target as any)) {
754
+ e.preventDefault();
755
+
756
+ // We need to calculate the pixel distance between the click point
757
+ // and the marker position, with the offset accounted for. Then we
758
+ // can subtract this distance from the mousemove event's position
759
+ // to calculate the new marker position.
760
+ // If we don't do this, the marker 'jumps' to the click position
761
+ // creating a jarring UX effect.
762
+ this._positionDelta = e.point.sub(this._pos).add(this._offset);
763
+
764
+ this._pointerdownPos = e.point;
765
+
766
+ this._state = 'pending';
767
+ this._map.on('mousemove', this._onMove);
768
+ this._map.on('touchmove', this._onMove);
769
+ this._map.once('mouseup', this._onUp);
770
+ this._map.once('touchend', this._onUp);
771
+ }
772
+ };
773
+
774
+ /**
775
+ * Sets the `draggable` property and functionality of the marker
776
+ * @param shouldBeDraggable - Turns drag functionality on/off
777
+ */
778
+ setDraggable(shouldBeDraggable?: boolean): this {
779
+ this._draggable = !!shouldBeDraggable; // convert possible undefined value to false
780
+
781
+ // handle case where map may not exist yet
782
+ // e.g. when setDraggable is called before addTo
783
+ if (this._map) {
784
+ if (shouldBeDraggable) {
785
+ this._map.on('mousedown', this._addDragHandler);
786
+ this._map.on('touchstart', this._addDragHandler);
787
+ } else {
788
+ this._map.off('mousedown', this._addDragHandler);
789
+ this._map.off('touchstart', this._addDragHandler);
790
+ }
791
+ }
792
+
793
+ return this;
794
+ }
795
+
796
+ /**
797
+ * Returns true if the marker can be dragged
798
+ * @returns True if the marker is draggable.
799
+ */
800
+ isDraggable(): boolean {
801
+ return this._draggable;
802
+ }
803
+
804
+ /**
805
+ * Sets the `rotation` property of the marker.
806
+ * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting.
807
+ */
808
+ setRotation(rotation?: number): this {
809
+ this._rotation = rotation || 0;
810
+ this._update();
811
+ return this;
812
+ }
813
+
814
+ /**
815
+ * Returns the current rotation angle of the marker (in degrees).
816
+ * @returns The current rotation angle of the marker.
817
+ */
818
+ getRotation(): number {
819
+ return this._rotation;
820
+ }
821
+
822
+ /**
823
+ * Sets the `rotationAlignment` property of the marker.
824
+ * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto'
825
+ */
826
+ setRotationAlignment(alignment?: Alignment): this {
827
+ this._rotationAlignment = alignment || 'auto';
828
+ this._update();
829
+ return this;
830
+ }
831
+
832
+ /**
833
+ * Returns the current `rotationAlignment` property of the marker.
834
+ * @returns The current rotational alignment of the marker.
835
+ */
836
+ getRotationAlignment(): Alignment {
837
+ return this._rotationAlignment;
838
+ }
839
+
840
+ /**
841
+ * Sets the `pitchAlignment` property of the marker.
842
+ * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.
843
+ */
844
+ setPitchAlignment(alignment?: Alignment): this {
845
+ this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;
846
+ this._update();
847
+ return this;
848
+ }
849
+
850
+ /**
851
+ * Returns the current `pitchAlignment` property of the marker.
852
+ * @returns The current pitch alignment of the marker in degrees.
853
+ */
854
+ getPitchAlignment(): Alignment {
855
+ return this._pitchAlignment;
856
+ }
857
+
858
+ /**
859
+ * Sets the `opacity` and `opacityWhenCovered` properties of the marker.
860
+ * When called without arguments, resets opacity and opacityWhenCovered to defaults
861
+ * @param opacity - Sets the `opacity` property of the marker.
862
+ * @param opacityWhenCovered - Sets the `opacityWhenCovered` property of the marker.
863
+ */
864
+ setOpacity(opacity?: string, opacityWhenCovered?: string): this {
865
+ if (opacity === undefined && opacityWhenCovered === undefined) {
866
+ this._opacity = '1';
867
+ this._opacityWhenCovered = '0.2';
868
+ }
869
+ if (opacity !== undefined) {
870
+ this._opacity = opacity;
871
+ }
872
+ if (opacityWhenCovered !== undefined) {
873
+ this._opacityWhenCovered = opacityWhenCovered;
874
+ }
875
+ if (this._map) {
876
+ this._updateOpacity(true);
877
+ }
878
+ return this;
879
+ }
880
+ }