@mapgis/mapbox-gl 16.0.0 → 16.2.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 (441) hide show
  1. package/dist/mapbox-gl.js +4 -4
  2. package/dist/mapbox-gl.js.map +1 -1
  3. package/package.json +4 -5
  4. package/.flowconfig +0 -61
  5. package/LICENSE.txt +0 -84
  6. package/README.md +0 -34
  7. package/build/banner.js +0 -4
  8. package/build/check-bundle-size.js +0 -140
  9. package/build/generate-access-token-script.js +0 -11
  10. package/build/generate-flow-typed-style-spec.js +0 -188
  11. package/build/generate-release-list.js +0 -21
  12. package/build/generate-struct-arrays.js +0 -237
  13. package/build/generate-style-code.js +0 -159
  14. package/build/mapbox-gl.js.flow +0 -3
  15. package/build/print-release-url.js +0 -6
  16. package/build/rollup_plugin_minify_style_spec.js +0 -20
  17. package/build/rollup_plugins.js +0 -80
  18. package/build/run-node +0 -3
  19. package/build/run-tap +0 -8
  20. package/build/test/build-tape.js +0 -19
  21. package/dist/mapbox-gl-csp-worker.js +0 -2
  22. package/dist/mapbox-gl-csp-worker.js.map +0 -1
  23. package/dist/mapbox-gl-csp.js +0 -2
  24. package/dist/mapbox-gl-csp.js.map +0 -1
  25. package/dist/mapbox-gl-dev.js +0 -68798
  26. package/dist/mapbox-gl-unminified.js +0 -45076
  27. package/dist/mapbox-gl-unminified.js.map +0 -1
  28. package/flow-typed/gl.js +0 -5
  29. package/flow-typed/jsdom.js +0 -18
  30. package/flow-typed/mapbox-gl-supported.js +0 -9
  31. package/flow-typed/mapbox-unitbezier.js +0 -14
  32. package/flow-typed/offscreen-canvas.js +0 -9
  33. package/flow-typed/pbf.js +0 -25
  34. package/flow-typed/point-geometry.js +0 -44
  35. package/flow-typed/potpack.js +0 -12
  36. package/flow-typed/sinon.js +0 -28
  37. package/flow-typed/vector-tile.js +0 -41
  38. package/src/css/mapbox-gl.css +0 -798
  39. package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
  40. package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
  41. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
  42. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
  43. package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
  44. package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
  45. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
  46. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
  47. package/src/data/array_types.js +0 -1095
  48. package/src/data/bucket/circle_attributes.js +0 -9
  49. package/src/data/bucket/circle_bucket.js +0 -204
  50. package/src/data/bucket/fill_attributes.js +0 -9
  51. package/src/data/bucket/fill_bucket.js +0 -233
  52. package/src/data/bucket/fill_extrusion_attributes.js +0 -10
  53. package/src/data/bucket/fill_extrusion_bucket.js +0 -289
  54. package/src/data/bucket/heatmap_bucket.js +0 -17
  55. package/src/data/bucket/line_attributes.js +0 -10
  56. package/src/data/bucket/line_bucket.js +0 -556
  57. package/src/data/bucket/pattern_attributes.js +0 -10
  58. package/src/data/bucket/pattern_bucket_features.js +0 -60
  59. package/src/data/bucket/symbol_attributes.js +0 -117
  60. package/src/data/bucket/symbol_bucket.js +0 -972
  61. package/src/data/bucket.js +0 -123
  62. package/src/data/dem_data.js +0 -125
  63. package/src/data/extent.js +0 -18
  64. package/src/data/feature_index.js +0 -321
  65. package/src/data/feature_position_map.js +0 -125
  66. package/src/data/index_array_type.js +0 -16
  67. package/src/data/load_geometry.js +0 -48
  68. package/src/data/pos_attributes.js +0 -6
  69. package/src/data/program_configuration.js +0 -687
  70. package/src/data/raster_bounds_attributes.js +0 -7
  71. package/src/data/segment.js +0 -76
  72. package/src/geo/edge_insets.js +0 -102
  73. package/src/geo/lng_lat.js +0 -165
  74. package/src/geo/lng_lat_bounds.js +0 -267
  75. package/src/geo/mercator_coordinate.js +0 -153
  76. package/src/geo/transform.js +0 -864
  77. package/src/gl/color_mode.js +0 -34
  78. package/src/gl/context.js +0 -298
  79. package/src/gl/cull_face_mode.js +0 -26
  80. package/src/gl/depth_mode.js +0 -29
  81. package/src/gl/framebuffer.js +0 -44
  82. package/src/gl/index_buffer.js +0 -55
  83. package/src/gl/stencil_mode.js +0 -30
  84. package/src/gl/types.js +0 -84
  85. package/src/gl/value.js +0 -520
  86. package/src/gl/vertex_buffer.js +0 -119
  87. package/src/index.js +0 -201
  88. package/src/render/draw_background.js +0 -57
  89. package/src/render/draw_circle.js +0 -113
  90. package/src/render/draw_collision_debug.js +0 -49
  91. package/src/render/draw_custom.js +0 -49
  92. package/src/render/draw_debug.js +0 -127
  93. package/src/render/draw_fill.js +0 -126
  94. package/src/render/draw_fill_extrusion.js +0 -96
  95. package/src/render/draw_heatmap.js +0 -140
  96. package/src/render/draw_hillshade.js +0 -108
  97. package/src/render/draw_line.js +0 -98
  98. package/src/render/draw_raster.js +0 -125
  99. package/src/render/draw_symbol.js +0 -394
  100. package/src/render/glyph_atlas.js +0 -71
  101. package/src/render/glyph_manager.js +0 -182
  102. package/src/render/image_atlas.js +0 -149
  103. package/src/render/image_manager.js +0 -306
  104. package/src/render/line_atlas.js +0 -210
  105. package/src/render/painter.js +0 -653
  106. package/src/render/program/background_program.js +0 -103
  107. package/src/render/program/circle_program.js +0 -69
  108. package/src/render/program/clipping_mask_program.js +0 -20
  109. package/src/render/program/collision_program.js +0 -49
  110. package/src/render/program/debug_program.js +0 -35
  111. package/src/render/program/fill_extrusion_program.js +0 -122
  112. package/src/render/program/fill_program.js +0 -126
  113. package/src/render/program/heatmap_program.js +0 -83
  114. package/src/render/program/hillshade_program.js +0 -122
  115. package/src/render/program/line_program.js +0 -207
  116. package/src/render/program/pattern.js +0 -102
  117. package/src/render/program/program_uniforms.js +0 -42
  118. package/src/render/program/raster_program.js +0 -92
  119. package/src/render/program/symbol_program.js +0 -224
  120. package/src/render/program.js +0 -168
  121. package/src/render/texture.js +0 -122
  122. package/src/render/uniform_binding.js +0 -147
  123. package/src/render/vertex_array_object.js +0 -163
  124. package/src/shaders/README.md +0 -42
  125. package/src/shaders/_prelude.fragment.glsl +0 -17
  126. package/src/shaders/_prelude.vertex.glsl +0 -73
  127. package/src/shaders/background.fragment.glsl +0 -10
  128. package/src/shaders/background.vertex.glsl +0 -7
  129. package/src/shaders/background_pattern.fragment.glsl +0 -28
  130. package/src/shaders/background_pattern.vertex.glsl +0 -20
  131. package/src/shaders/circle.fragment.glsl +0 -39
  132. package/src/shaders/circle.vertex.glsl +0 -64
  133. package/src/shaders/clipping_mask.fragment.glsl +0 -3
  134. package/src/shaders/clipping_mask.vertex.glsl +0 -7
  135. package/src/shaders/collision_box.fragment.glsl +0 -21
  136. package/src/shaders/collision_box.vertex.glsl +0 -27
  137. package/src/shaders/collision_circle.fragment.glsl +0 -34
  138. package/src/shaders/collision_circle.vertex.glsl +0 -36
  139. package/src/shaders/debug.fragment.glsl +0 -9
  140. package/src/shaders/debug.vertex.glsl +0 -12
  141. package/src/shaders/encode_attribute.js +0 -17
  142. package/src/shaders/fill.fragment.glsl +0 -13
  143. package/src/shaders/fill.vertex.glsl +0 -13
  144. package/src/shaders/fill_extrusion.fragment.glsl +0 -9
  145. package/src/shaders/fill_extrusion.vertex.glsl +0 -66
  146. package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
  147. package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
  148. package/src/shaders/fill_outline.fragment.glsl +0 -17
  149. package/src/shaders/fill_outline.vertex.glsl +0 -17
  150. package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
  151. package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
  152. package/src/shaders/fill_pattern.fragment.glsl +0 -36
  153. package/src/shaders/fill_pattern.vertex.glsl +0 -39
  154. package/src/shaders/heatmap.fragment.glsl +0 -22
  155. package/src/shaders/heatmap.vertex.glsl +0 -54
  156. package/src/shaders/heatmap_texture.fragment.glsl +0 -14
  157. package/src/shaders/heatmap_texture.vertex.glsl +0 -11
  158. package/src/shaders/hillshade.fragment.glsl +0 -52
  159. package/src/shaders/hillshade.vertex.glsl +0 -11
  160. package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
  161. package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
  162. package/src/shaders/index.js +0 -20
  163. package/src/shaders/line.fragment.glsl +0 -30
  164. package/src/shaders/line.vertex.glsl +0 -85
  165. package/src/shaders/line_gradient.fragment.glsl +0 -34
  166. package/src/shaders/line_gradient.vertex.glsl +0 -87
  167. package/src/shaders/line_pattern.fragment.glsl +0 -74
  168. package/src/shaders/line_pattern.vertex.glsl +0 -99
  169. package/src/shaders/line_sdf.fragment.glsl +0 -45
  170. package/src/shaders/line_sdf.vertex.glsl +0 -98
  171. package/src/shaders/raster.fragment.glsl +0 -52
  172. package/src/shaders/raster.vertex.glsl +0 -21
  173. package/src/shaders/shaders.js +0 -180
  174. package/src/shaders/symbol_icon.fragment.glsl +0 -17
  175. package/src/shaders/symbol_icon.vertex.glsl +0 -94
  176. package/src/shaders/symbol_sdf.fragment.glsl +0 -52
  177. package/src/shaders/symbol_sdf.vertex.glsl +0 -115
  178. package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
  179. package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
  180. package/src/source/canvas_source.js +0 -238
  181. package/src/source/geojson_helper.js +0 -92
  182. package/src/source/geojson_source.js +0 -374
  183. package/src/source/geojson_worker_source.js +0 -357
  184. package/src/source/geojson_wrapper.js +0 -94
  185. package/src/source/image_source.js +0 -307
  186. package/src/source/load_tilejson.js +0 -39
  187. package/src/source/mbtiles_source.js +0 -115
  188. package/src/source/offline_database.js +0 -61
  189. package/src/source/offline_database_root.js +0 -62
  190. package/src/source/pixels_to_tile_units.js +0 -21
  191. package/src/source/query_features.js +0 -208
  192. package/src/source/raster_dem_tile_source.js +0 -138
  193. package/src/source/raster_dem_tile_worker_source.js +0 -62
  194. package/src/source/raster_tile_offline_source.js +0 -136
  195. package/src/source/raster_tile_source.js +0 -177
  196. package/src/source/rtl_text_plugin.js +0 -138
  197. package/src/source/source.js +0 -137
  198. package/src/source/source_cache.js +0 -957
  199. package/src/source/source_state.js +0 -159
  200. package/src/source/tile.js +0 -465
  201. package/src/source/tile_bounds.js +0 -38
  202. package/src/source/tile_cache.js +0 -212
  203. package/src/source/tile_id.js +0 -402
  204. package/src/source/vector_tile_source.js +0 -192
  205. package/src/source/vector_tile_worker_source.js +0 -216
  206. package/src/source/video_source.js +0 -203
  207. package/src/source/worker.js +0 -237
  208. package/src/source/worker_source.js +0 -106
  209. package/src/source/worker_tile.js +0 -224
  210. package/src/style/create_style_layer.js +0 -36
  211. package/src/style/evaluation_parameters.js +0 -62
  212. package/src/style/light.js +0 -130
  213. package/src/style/load_glyph_range.js +0 -38
  214. package/src/style/load_sprite.js +0 -67
  215. package/src/style/parse_glyph_pbf.js +0 -44
  216. package/src/style/pauseable_placement.js +0 -132
  217. package/src/style/properties.js +0 -753
  218. package/src/style/query_utils.js +0 -43
  219. package/src/style/style.js +0 -1361
  220. package/src/style/style_glyph.js +0 -17
  221. package/src/style/style_image.js +0 -137
  222. package/src/style/style_layer/background_style_layer.js +0 -21
  223. package/src/style/style_layer/background_style_layer_properties.js +0 -40
  224. package/src/style/style_layer/circle_style_layer.js +0 -98
  225. package/src/style/style_layer/circle_style_layer_properties.js +0 -63
  226. package/src/style/style_layer/custom_style_layer.js +0 -223
  227. package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
  228. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
  229. package/src/style/style_layer/fill_style_layer.js +0 -67
  230. package/src/style/style_layer/fill_style_layer_properties.js +0 -55
  231. package/src/style/style_layer/heatmap_style_layer.js +0 -69
  232. package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
  233. package/src/style/style_layer/hillshade_style_layer.js +0 -25
  234. package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
  235. package/src/style/style_layer/layer_properties.js.ejs +0 -69
  236. package/src/style/style_layer/line_style_layer.js +0 -151
  237. package/src/style/style_layer/line_style_layer_properties.js +0 -71
  238. package/src/style/style_layer/raster_style_layer.js +0 -21
  239. package/src/style/style_layer/raster_style_layer_properties.js +0 -50
  240. package/src/style/style_layer/symbol_style_layer.js +0 -190
  241. package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
  242. package/src/style/style_layer/typed_style_layer.js +0 -17
  243. package/src/style/style_layer.js +0 -281
  244. package/src/style/style_layer_index.js +0 -80
  245. package/src/style/validate_style.js +0 -42
  246. package/src/style/zoom_history.js +0 -44
  247. package/src/style-spec/.eslintrc +0 -5
  248. package/src/style-spec/CHANGELOG.md +0 -438
  249. package/src/style-spec/README.md +0 -59
  250. package/src/style-spec/bin/gl-style-composite +0 -9
  251. package/src/style-spec/bin/gl-style-format +0 -22
  252. package/src/style-spec/bin/gl-style-migrate +0 -9
  253. package/src/style-spec/bin/gl-style-validate +0 -50
  254. package/src/style-spec/composite.js +0 -50
  255. package/src/style-spec/declass.js +0 -42
  256. package/src/style-spec/deref.js +0 -52
  257. package/src/style-spec/diff.js +0 -393
  258. package/src/style-spec/dist/.gitkeep +0 -0
  259. package/src/style-spec/empty.js +0 -29
  260. package/src/style-spec/error/parsing_error.js +0 -16
  261. package/src/style-spec/error/validation_error.js +0 -18
  262. package/src/style-spec/expression/compound_expression.js +0 -162
  263. package/src/style-spec/expression/definitions/assertion.js +0 -130
  264. package/src/style-spec/expression/definitions/at.js +0 -70
  265. package/src/style-spec/expression/definitions/case.js +0 -85
  266. package/src/style-spec/expression/definitions/coalesce.js +0 -93
  267. package/src/style-spec/expression/definitions/coercion.js +0 -133
  268. package/src/style-spec/expression/definitions/collator.js +0 -78
  269. package/src/style-spec/expression/definitions/comparison.js +0 -184
  270. package/src/style-spec/expression/definitions/format.js +0 -144
  271. package/src/style-spec/expression/definitions/format_section_override.js +0 -54
  272. package/src/style-spec/expression/definitions/image.js +0 -52
  273. package/src/style-spec/expression/definitions/in.js +0 -92
  274. package/src/style-spec/expression/definitions/index.js +0 -561
  275. package/src/style-spec/expression/definitions/interpolate.js +0 -267
  276. package/src/style-spec/expression/definitions/length.js +0 -61
  277. package/src/style-spec/expression/definitions/let.js +0 -72
  278. package/src/style-spec/expression/definitions/literal.js +0 -77
  279. package/src/style-spec/expression/definitions/match.js +0 -158
  280. package/src/style-spec/expression/definitions/number_format.js +0 -142
  281. package/src/style-spec/expression/definitions/step.js +0 -120
  282. package/src/style-spec/expression/definitions/var.js +0 -46
  283. package/src/style-spec/expression/definitions/within.js +0 -333
  284. package/src/style-spec/expression/evaluation_context.js +0 -59
  285. package/src/style-spec/expression/expression.js +0 -27
  286. package/src/style-spec/expression/index.js +0 -392
  287. package/src/style-spec/expression/is_constant.js +0 -59
  288. package/src/style-spec/expression/parsing_context.js +0 -233
  289. package/src/style-spec/expression/parsing_error.js +0 -13
  290. package/src/style-spec/expression/runtime_error.js +0 -17
  291. package/src/style-spec/expression/scope.js +0 -36
  292. package/src/style-spec/expression/stops.js +0 -39
  293. package/src/style-spec/expression/types/collator.js +0 -61
  294. package/src/style-spec/expression/types/formatted.js +0 -73
  295. package/src/style-spec/expression/types/resolved_image.js +0 -29
  296. package/src/style-spec/expression/types.js +0 -106
  297. package/src/style-spec/expression/values.js +0 -123
  298. package/src/style-spec/feature_filter/README.md +0 -55
  299. package/src/style-spec/feature_filter/convert.js +0 -208
  300. package/src/style-spec/feature_filter/index.js +0 -165
  301. package/src/style-spec/format.js +0 -51
  302. package/src/style-spec/function/convert.js +0 -254
  303. package/src/style-spec/function/index.js +0 -262
  304. package/src/style-spec/group_by_layout.js +0 -75
  305. package/src/style-spec/migrate/expressions.js +0 -39
  306. package/src/style-spec/migrate/v8.js +0 -203
  307. package/src/style-spec/migrate/v9.js +0 -26
  308. package/src/style-spec/migrate.js +0 -36
  309. package/src/style-spec/package.json +0 -41
  310. package/src/style-spec/read_style.js +0 -14
  311. package/src/style-spec/reference/latest.js +0 -3
  312. package/src/style-spec/reference/v8.json +0 -5808
  313. package/src/style-spec/rollup.config.js +0 -45
  314. package/src/style-spec/style-spec.js +0 -122
  315. package/src/style-spec/types.js +0 -438
  316. package/src/style-spec/util/color.js +0 -95
  317. package/src/style-spec/util/color_spaces.js +0 -139
  318. package/src/style-spec/util/deep_equal.js +0 -28
  319. package/src/style-spec/util/extend.js +0 -10
  320. package/src/style-spec/util/get_type.js +0 -17
  321. package/src/style-spec/util/interpolate.js +0 -22
  322. package/src/style-spec/util/properties.js +0 -15
  323. package/src/style-spec/util/ref_properties.js +0 -2
  324. package/src/style-spec/util/result.js +0 -19
  325. package/src/style-spec/util/unbundle_jsonlint.js +0 -24
  326. package/src/style-spec/validate/latest.js +0 -11
  327. package/src/style-spec/validate/validate.js +0 -75
  328. package/src/style-spec/validate/validate_array.js +0 -52
  329. package/src/style-spec/validate/validate_boolean.js +0 -15
  330. package/src/style-spec/validate/validate_color.js +0 -20
  331. package/src/style-spec/validate/validate_constants.js +0 -13
  332. package/src/style-spec/validate/validate_enum.js +0 -21
  333. package/src/style-spec/validate/validate_expression.js +0 -43
  334. package/src/style-spec/validate/validate_filter.js +0 -111
  335. package/src/style-spec/validate/validate_formatted.js +0 -11
  336. package/src/style-spec/validate/validate_function.js +0 -207
  337. package/src/style-spec/validate/validate_glyphs_url.js +0 -21
  338. package/src/style-spec/validate/validate_image.js +0 -11
  339. package/src/style-spec/validate/validate_layer.js +0 -134
  340. package/src/style-spec/validate/validate_layout_property.js +0 -6
  341. package/src/style-spec/validate/validate_light.js +0 -47
  342. package/src/style-spec/validate/validate_number.js +0 -29
  343. package/src/style-spec/validate/validate_object.js +0 -61
  344. package/src/style-spec/validate/validate_paint_property.js +0 -6
  345. package/src/style-spec/validate/validate_property.js +0 -64
  346. package/src/style-spec/validate/validate_source.js +0 -111
  347. package/src/style-spec/validate/validate_string.js +0 -15
  348. package/src/style-spec/validate_mapbox_api_supported.js +0 -171
  349. package/src/style-spec/validate_style.js +0 -39
  350. package/src/style-spec/validate_style.min.js +0 -78
  351. package/src/style-spec/visit.js +0 -77
  352. package/src/symbol/anchor.js +0 -26
  353. package/src/symbol/check_max_angle.js +0 -81
  354. package/src/symbol/clip_line.js +0 -71
  355. package/src/symbol/collision_feature.js +0 -217
  356. package/src/symbol/collision_index.js +0 -372
  357. package/src/symbol/cross_tile_symbol_index.js +0 -301
  358. package/src/symbol/get_anchors.js +0 -167
  359. package/src/symbol/grid_index.js +0 -335
  360. package/src/symbol/mergelines.js +0 -82
  361. package/src/symbol/one_em.js +0 -4
  362. package/src/symbol/opacity_state.js +0 -27
  363. package/src/symbol/placement.js +0 -1062
  364. package/src/symbol/projection.js +0 -450
  365. package/src/symbol/quads.js +0 -334
  366. package/src/symbol/shaping.js +0 -816
  367. package/src/symbol/symbol_layout.js +0 -772
  368. package/src/symbol/symbol_size.js +0 -113
  369. package/src/symbol/transform_text.js +0 -29
  370. package/src/types/callback.js +0 -17
  371. package/src/types/cancelable.js +0 -3
  372. package/src/types/tilejson.js +0 -17
  373. package/src/types/transferable.js +0 -3
  374. package/src/types/window.js +0 -172
  375. package/src/ui/anchor.js +0 -32
  376. package/src/ui/bind_handlers.js +0 -202
  377. package/src/ui/camera.js +0 -1152
  378. package/src/ui/control/attribution_control.js +0 -189
  379. package/src/ui/control/fps_control.js +0 -185
  380. package/src/ui/control/fullscreen_control.js +0 -147
  381. package/src/ui/control/geolocate_control.js +0 -594
  382. package/src/ui/control/logo_control.js +0 -92
  383. package/src/ui/control/navigation_control.js +0 -148
  384. package/src/ui/control/scale_control.js +0 -142
  385. package/src/ui/crs.js +0 -64
  386. package/src/ui/default_locale.js +0 -20
  387. package/src/ui/events.js +0 -806
  388. package/src/ui/handler/box_zoom.js +0 -175
  389. package/src/ui/handler/dblclick_zoom.js +0 -139
  390. package/src/ui/handler/drag_pan.js +0 -416
  391. package/src/ui/handler/drag_rotate.js +0 -378
  392. package/src/ui/handler/keyboard.js +0 -161
  393. package/src/ui/handler/scroll_zoom.js +0 -333
  394. package/src/ui/handler/touch_zoom_rotate.js +0 -293
  395. package/src/ui/hash.js +0 -147
  396. package/src/ui/map.js +0 -2883
  397. package/src/ui/marker.js +0 -607
  398. package/src/ui/offline_map.js +0 -91
  399. package/src/ui/popup.js +0 -530
  400. package/src/util/actor.js +0 -212
  401. package/src/util/ajax.js +0 -371
  402. package/src/util/browser/web_worker.js +0 -10
  403. package/src/util/browser/window.js +0 -5
  404. package/src/util/browser.js +0 -70
  405. package/src/util/classify_rings.js +0 -52
  406. package/src/util/color_ramp.js +0 -28
  407. package/src/util/config.js +0 -30
  408. package/src/util/debug.js +0 -12
  409. package/src/util/dictionary_coder.js +0 -30
  410. package/src/util/dispatcher.js +0 -70
  411. package/src/util/dom.js +0 -144
  412. package/src/util/evented.js +0 -174
  413. package/src/util/find_pole_of_inaccessibility.js +0 -129
  414. package/src/util/global_worker_pool.js +0 -17
  415. package/src/util/image.js +0 -142
  416. package/src/util/intersection_tests.js +0 -208
  417. package/src/util/is_char_in_unicode_block.js +0 -311
  418. package/src/util/mapbox.js +0 -486
  419. package/src/util/offscreen_canvas_supported.js +0 -14
  420. package/src/util/performance.js +0 -112
  421. package/src/util/primitives.js +0 -145
  422. package/src/util/resolve_tokens.js +0 -16
  423. package/src/util/script_detection.js +0 -328
  424. package/src/util/sku_token.js +0 -42
  425. package/src/util/smart_wrap.js +0 -55
  426. package/src/util/struct_array.js +0 -243
  427. package/src/util/struct_array.js.ejs +0 -112
  428. package/src/util/struct_array_layout.js.ejs +0 -98
  429. package/src/util/task_queue.js +0 -68
  430. package/src/util/throttle.js +0 -28
  431. package/src/util/throttled_invoker.js +0 -46
  432. package/src/util/tile_cover.js +0 -101
  433. package/src/util/tile_request_cache.js +0 -172
  434. package/src/util/util.js +0 -504
  435. package/src/util/vectortile_to_geojson.js +0 -54
  436. package/src/util/verticalize_punctuation.js +0 -114
  437. package/src/util/web_worker.js +0 -91
  438. package/src/util/web_worker_transfer.js +0 -266
  439. package/src/util/webp_supported.js +0 -69
  440. package/src/util/window.js +0 -102
  441. package/src/util/worker_pool.js +0 -47
package/src/ui/marker.js DELETED
@@ -1,607 +0,0 @@
1
- // @flow
2
-
3
- import DOM from '../util/dom';
4
- import window from '../util/window';
5
- import LngLat from '../geo/lng_lat';
6
- import Point from '@mapbox/point-geometry';
7
- import smartWrap from '../util/smart_wrap';
8
- import {bindAll, extend} from '../util/util';
9
- import {type Anchor, anchorTranslate, applyAnchorClass} from './anchor';
10
- import {Event, Evented} from '../util/evented';
11
- import type Map from './map';
12
- import type Popup from './popup';
13
- import type {LngLatLike} from "../geo/lng_lat";
14
- import type {MapMouseEvent, MapTouchEvent} from './events';
15
- import type {PointLike} from '@mapbox/point-geometry';
16
-
17
- type Options = {
18
- element?: HTMLElement,
19
- offset?: PointLike,
20
- anchor?: Anchor,
21
- color?: string,
22
- draggable?: boolean,
23
- rotation?: number,
24
- rotationAlignment?: string,
25
- pitchAlignment?: string
26
- };
27
-
28
- /**
29
- * Creates a marker component
30
- * @param {Object} [options]
31
- * @param {HTMLElement} [options.element] DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.
32
- * @param {string} [options.anchor='center'] A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.
33
- * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.
34
- * @param {PointLike} [options.offset] The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
35
- * @param {string} [options.color='#3FB1CE'] The color to use for the default marker if options.element is not provided. The default is light blue.
36
- * @param {boolean} [options.draggable=false] A boolean indicating whether or not a marker is able to be dragged to a new position on the map.
37
- * @param {number} [options.rotation=0] The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.
38
- * @param {string} [options.pitchAlignment='auto'] `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`.
39
- * @param {string} [options.rotationAlignment='auto'] `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`.
40
- * @example
41
- * var marker = new mapboxgl.Marker()
42
- * .setLngLat([30.5, 50.5])
43
- * .addTo(map);
44
- * @see [Add custom icons with Markers](https://www.mapbox.com/mapbox-gl-js/example/custom-marker-icons/)
45
- * @see [Create a draggable Marker](https://www.mapbox.com/mapbox-gl-js/example/drag-a-marker/)
46
- */
47
- export default class Marker extends Evented {
48
- _map: Map;
49
- _anchor: Anchor;
50
- _offset: Point;
51
- _element: HTMLElement;
52
- _popup: ?Popup;
53
- _lngLat: LngLat;
54
- _pos: ?Point;
55
- _color: ?string;
56
- _defaultMarker: boolean;
57
- _draggable: boolean;
58
- _state: 'inactive' | 'pending' | 'active'; // used for handling drag events
59
- _positionDelta: ?number;
60
- _rotation: number;
61
- _pitchAlignment: string;
62
- _rotationAlignment: string;
63
- _originalTabIndex: ?string; // original tabindex of _element
64
-
65
- constructor(options?: Options, legacyOptions?: Options) {
66
- super();
67
- // For backward compatibility -- the constructor used to accept the element as a
68
- // required first argument, before it was made optional.
69
- if (options instanceof window.HTMLElement || legacyOptions) {
70
- options = extend({element: options}, legacyOptions);
71
- }
72
-
73
- bindAll([
74
- '_update',
75
- '_onMove',
76
- '_onUp',
77
- '_addDragHandler',
78
- '_onMapClick',
79
- '_onKeyPress'
80
- ], this);
81
-
82
- this._anchor = options && options.anchor || 'center';
83
- this._color = options && options.color || '#3FB1CE';
84
- this._draggable = options && options.draggable || false;
85
- this._state = 'inactive';
86
- this._rotation = options && options.rotation || 0;
87
- this._rotationAlignment = options && options.rotationAlignment || 'auto';
88
- this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment;
89
-
90
- if (!options || !options.element) {
91
- this._defaultMarker = true;
92
- this._element = DOM.create('div');
93
- this._element.setAttribute('aria-label', 'Map marker');
94
-
95
- // create default map marker SVG
96
- const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg');
97
- svg.setAttributeNS(null, 'display', 'block');
98
- svg.setAttributeNS(null, 'height', '41px');
99
- svg.setAttributeNS(null, 'width', '27px');
100
- svg.setAttributeNS(null, 'viewBox', '0 0 27 41');
101
-
102
- const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g');
103
- markerLarge.setAttributeNS(null, 'stroke', 'none');
104
- markerLarge.setAttributeNS(null, 'stroke-width', '1');
105
- markerLarge.setAttributeNS(null, 'fill', 'none');
106
- markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd');
107
-
108
- const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g');
109
- page1.setAttributeNS(null, 'fill-rule', 'nonzero');
110
-
111
- const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g');
112
- shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)');
113
- shadow.setAttributeNS(null, 'fill', '#000000');
114
-
115
- const ellipses = [
116
- {'rx': '10.5', 'ry': '5.25002273'},
117
- {'rx': '10.5', 'ry': '5.25002273'},
118
- {'rx': '9.5', 'ry': '4.77275007'},
119
- {'rx': '8.5', 'ry': '4.29549936'},
120
- {'rx': '7.5', 'ry': '3.81822308'},
121
- {'rx': '6.5', 'ry': '3.34094679'},
122
- {'rx': '5.5', 'ry': '2.86367051'},
123
- {'rx': '4.5', 'ry': '2.38636864'}
124
- ];
125
-
126
- for (const data of ellipses) {
127
- const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse');
128
- ellipse.setAttributeNS(null, 'opacity', '0.04');
129
- ellipse.setAttributeNS(null, 'cx', '10.5');
130
- ellipse.setAttributeNS(null, 'cy', '5.80029008');
131
- ellipse.setAttributeNS(null, 'rx', data['rx']);
132
- ellipse.setAttributeNS(null, 'ry', data['ry']);
133
- shadow.appendChild(ellipse);
134
- }
135
-
136
- const background = DOM.createNS('http://www.w3.org/2000/svg', 'g');
137
- background.setAttributeNS(null, 'fill', this._color);
138
-
139
- const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');
140
- 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');
141
-
142
- background.appendChild(bgPath);
143
-
144
- const border = DOM.createNS('http://www.w3.org/2000/svg', 'g');
145
- border.setAttributeNS(null, 'opacity', '0.25');
146
- border.setAttributeNS(null, 'fill', '#000000');
147
-
148
- const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');
149
- 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');
150
-
151
- border.appendChild(borderPath);
152
-
153
- const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g');
154
- maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)');
155
- maki.setAttributeNS(null, 'fill', '#FFFFFF');
156
-
157
- const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g');
158
- circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)');
159
-
160
- const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');
161
- circle1.setAttributeNS(null, 'fill', '#000000');
162
- circle1.setAttributeNS(null, 'opacity', '0.25');
163
- circle1.setAttributeNS(null, 'cx', '5.5');
164
- circle1.setAttributeNS(null, 'cy', '5.5');
165
- circle1.setAttributeNS(null, 'r', '5.4999962');
166
-
167
- const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');
168
- circle2.setAttributeNS(null, 'fill', '#FFFFFF');
169
- circle2.setAttributeNS(null, 'cx', '5.5');
170
- circle2.setAttributeNS(null, 'cy', '5.5');
171
- circle2.setAttributeNS(null, 'r', '5.4999962');
172
-
173
- circleContainer.appendChild(circle1);
174
- circleContainer.appendChild(circle2);
175
-
176
- page1.appendChild(shadow);
177
- page1.appendChild(background);
178
- page1.appendChild(border);
179
- page1.appendChild(maki);
180
- page1.appendChild(circleContainer);
181
-
182
- svg.appendChild(page1);
183
-
184
- this._element.appendChild(svg);
185
-
186
- // if no element and no offset option given apply an offset for the default marker
187
- // the -14 as the y value of the default marker offset was determined as follows
188
- //
189
- // the marker tip is at the center of the shadow ellipse from the default svg
190
- // 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)"
191
- // offset to the svg center "height (41 / 2)" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14
192
- // negative is used to move the marker up from the center so the tip is at the Marker lngLat
193
- this._offset = Point.convert(options && options.offset || [0, -14]);
194
- } else {
195
- this._element = options.element;
196
- this._offset = Point.convert(options && options.offset || [0, 0]);
197
- }
198
-
199
- this._element.classList.add('mapboxgl-marker');
200
- this._element.addEventListener('dragstart', (e: DragEvent) => {
201
- e.preventDefault();
202
- });
203
- this._element.addEventListener('mousedown', (e: MouseEvent) => {
204
- // prevent focusing on click
205
- e.preventDefault();
206
- });
207
- this._element.addEventListener('focus', () => {
208
- // revert the default scrolling action of the container
209
- const el = this._map.getContainer();
210
- el.scrollTop = 0;
211
- el.scrollLeft = 0;
212
- });
213
- applyAnchorClass(this._element, this._anchor, 'marker');
214
-
215
- this._popup = null;
216
- }
217
-
218
- /**
219
- * Attaches the marker to a map
220
- * @param {Map} map The Mapbox GL JS map to add the marker to.
221
- * @returns {Marker} `this`
222
- */
223
- addTo(map: Map) {
224
- this.remove();
225
- this._map = map;
226
- map.getCanvasContainer().appendChild(this._element);
227
- map.on('move', this._update);
228
- map.on('moveend', this._update);
229
- this.setDraggable(this._draggable);
230
- this._update();
231
-
232
- // If we attached the `click` listener to the marker element, the popup
233
- // would close once the event propogated to `map` due to the
234
- // `Popup#_onClickClose` listener.
235
- this._map.on('click', this._onMapClick);
236
-
237
- return this;
238
- }
239
-
240
- /**
241
- * Removes the marker from a map
242
- * @example
243
- * var marker = new mapboxgl.Marker().addTo(map);
244
- * marker.remove();
245
- * @returns {Marker} `this`
246
- */
247
- remove() {
248
- if (this._map) {
249
- this._map.off('click', this._onMapClick);
250
- this._map.off('move', this._update);
251
- this._map.off('moveend', this._update);
252
- this._map.off('mousedown', this._addDragHandler);
253
- this._map.off('touchstart', this._addDragHandler);
254
- this._map.off('mouseup', this._onUp);
255
- this._map.off('touchend', this._onUp);
256
- this._map.off('mousemove', this._onMove);
257
- this._map.off('touchmove', this._onMove);
258
- delete this._map;
259
- }
260
- DOM.remove(this._element);
261
- if (this._popup) this._popup.remove();
262
- return this;
263
- }
264
-
265
- /**
266
- * Get the marker's geographical location.
267
- *
268
- * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously
269
- * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep
270
- * the marker on screen.
271
- *
272
- * @returns {LngLat} A {@link LngLat} describing the marker's location.
273
- */
274
- getLngLat() {
275
- return this._lngLat;
276
- }
277
-
278
- /**
279
- * Set the marker's geographical position and move it.
280
- * @param {LngLat} lnglat A {@link LngLat} describing where the marker should be located.
281
- * @returns {Marker} `this`
282
- */
283
- setLngLat(lnglat: LngLatLike) {
284
- this._lngLat = LngLat.convert(lnglat);
285
- this._pos = null;
286
- if (this._popup) this._popup.setLngLat(this._lngLat);
287
- this._update();
288
- return this;
289
- }
290
-
291
- /**
292
- * Returns the `Marker`'s HTML element.
293
- * @returns {HTMLElement} element
294
- */
295
- getElement() {
296
- return this._element;
297
- }
298
-
299
- /**
300
- * Binds a Popup to the Marker
301
- * @param popup an instance of the `Popup` class. If undefined or null, any popup
302
- * set on this `Marker` instance is unset
303
- * @returns {Marker} `this`
304
- */
305
- setPopup(popup: ?Popup) {
306
- if (this._popup) {
307
- this._popup.remove();
308
- this._popup = null;
309
- this._element.removeEventListener('keypress', this._onKeyPress);
310
-
311
- if (!this._originalTabIndex) {
312
- this._element.removeAttribute('tabindex');
313
- }
314
- }
315
-
316
- if (popup) {
317
- if (!('offset' in popup.options)) {
318
- const markerHeight = 41 - (5.8 / 2);
319
- const markerRadius = 13.5;
320
- const linearOffset = Math.sqrt(Math.pow(markerRadius, 2) / 2);
321
- popup.options.offset = this._defaultMarker ? {
322
- 'top': [0, 0],
323
- 'top-left': [0, 0],
324
- 'top-right': [0, 0],
325
- 'bottom': [0, -markerHeight],
326
- 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
327
- 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
328
- 'left': [markerRadius, (markerHeight - markerRadius) * -1],
329
- 'right': [-markerRadius, (markerHeight - markerRadius) * -1]
330
- } : this._offset;
331
- }
332
- this._popup = popup;
333
- if (this._lngLat) this._popup.setLngLat(this._lngLat);
334
-
335
- this._originalTabIndex = this._element.getAttribute('tabindex');
336
- if (!this._originalTabIndex) {
337
- this._element.setAttribute('tabindex', '0');
338
- }
339
- this._element.addEventListener('keypress', this._onKeyPress);
340
- }
341
-
342
- return this;
343
- }
344
-
345
- _onKeyPress(e: KeyboardEvent) {
346
- const code = e.code;
347
- const legacyCode = e.charCode || e.keyCode;
348
-
349
- if (
350
- (code === 'Space') || (code === 'Enter') ||
351
- (legacyCode === 32) || (legacyCode === 13) // space or enter
352
- ) {
353
- this.togglePopup();
354
- }
355
- }
356
-
357
- _onMapClick(e: MapMouseEvent) {
358
- const targetElement = e.originalEvent.target;
359
- const element = this._element;
360
-
361
- if (this._popup && (targetElement === element || element.contains((targetElement: any)))) {
362
- this.togglePopup();
363
- }
364
- }
365
-
366
- /**
367
- * Returns the Popup instance that is bound to the Marker
368
- * @returns {Popup} popup
369
- */
370
- getPopup() {
371
- return this._popup;
372
- }
373
-
374
- /**
375
- * Opens or closes the bound popup, depending on the current state
376
- * @returns {Marker} `this`
377
- */
378
- togglePopup() {
379
- const popup = this._popup;
380
-
381
- if (!popup) return this;
382
- else if (popup.isOpen()) popup.remove();
383
- else popup.addTo(this._map);
384
- return this;
385
- }
386
-
387
- _update(e?: {type: 'move' | 'moveend'}) {
388
- if (!this._map) return;
389
-
390
- if (this._map.transform.renderWorldCopies) {
391
- this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);
392
- }
393
-
394
- this._pos = this._map.project(this._lngLat)._add(this._offset);
395
-
396
- let rotation = "";
397
- if (this._rotationAlignment === "viewport" || this._rotationAlignment === "auto") {
398
- rotation = `rotateZ(${this._rotation}deg)`;
399
- } else if (this._rotationAlignment === "map") {
400
- rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`;
401
- }
402
-
403
- let pitch = "";
404
- if (this._pitchAlignment === "viewport" || this._pitchAlignment === "auto") {
405
- pitch = "rotateX(0deg)";
406
- } else if (this._pitchAlignment === "map") {
407
- pitch = `rotateX(${this._map.getPitch()}deg)`;
408
- }
409
-
410
- // because rounding the coordinates at every `move` event causes stuttered zooming
411
- // we only round them when _update is called with `moveend` or when its called with
412
- // no arguments (when the Marker is initialized or Marker#setLngLat is invoked).
413
- if (!e || e.type === "moveend") {
414
- this._pos = this._pos.round();
415
- }
416
-
417
- DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);
418
- }
419
-
420
- /**
421
- * Get the marker's offset.
422
- * @returns {Point} The marker's screen coordinates in pixels.
423
- */
424
- getOffset() {
425
- return this._offset;
426
- }
427
-
428
- /**
429
- * Sets the offset of the marker
430
- * @param {PointLike} offset The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
431
- * @returns {Marker} `this`
432
- */
433
- setOffset(offset: PointLike) {
434
- this._offset = Point.convert(offset);
435
- this._update();
436
- return this;
437
- }
438
-
439
- _onMove(e: MapMouseEvent | MapTouchEvent) {
440
- this._pos = e.point.sub(this._positionDelta);
441
- this._lngLat = this._map.unproject(this._pos);
442
- this.setLngLat(this._lngLat);
443
- // suppress click event so that popups don't toggle on drag
444
- this._element.style.pointerEvents = 'none';
445
-
446
- // make sure dragstart only fires on the first move event after mousedown.
447
- // this can't be on mousedown because that event doesn't necessarily
448
- // imply that a drag is about to happen.
449
- if (this._state === 'pending') {
450
- this._state = 'active';
451
-
452
- /**
453
- * Fired when dragging starts
454
- *
455
- * @event dragstart
456
- * @memberof Marker
457
- * @instance
458
- * @type {Object}
459
- * @property {Marker} marker object that is being dragged
460
- */
461
- this.fire(new Event('dragstart'));
462
- }
463
-
464
- /**
465
- * Fired while dragging
466
- *
467
- * @event drag
468
- * @memberof Marker
469
- * @instance
470
- * @type {Object}
471
- * @property {Marker} marker object that is being dragged
472
- */
473
- this.fire(new Event('drag'));
474
- }
475
-
476
- _onUp() {
477
- // revert to normal pointer event handling
478
- this._element.style.pointerEvents = 'auto';
479
- this._positionDelta = null;
480
- this._map.off('mousemove', this._onMove);
481
- this._map.off('touchmove', this._onMove);
482
-
483
- // only fire dragend if it was preceded by at least one drag event
484
- if (this._state === 'active') {
485
- /**
486
- * Fired when the marker is finished being dragged
487
- *
488
- * @event dragend
489
- * @memberof Marker
490
- * @instance
491
- * @type {Object}
492
- * @property {Marker} marker object that was dragged
493
- */
494
- this.fire(new Event('dragend'));
495
- }
496
-
497
- this._state = 'inactive';
498
- }
499
-
500
- _addDragHandler(e: MapMouseEvent | MapTouchEvent) {
501
- if (this._element.contains((e.originalEvent.target: any))) {
502
- e.preventDefault();
503
-
504
- // We need to calculate the pixel distance between the click point
505
- // and the marker position, with the offset accounted for. Then we
506
- // can subtract this distance from the mousemove event's position
507
- // to calculate the new marker position.
508
- // If we don't do this, the marker 'jumps' to the click position
509
- // creating a jarring UX effect.
510
- this._positionDelta = e.point.sub(this._pos).add(this._offset);
511
-
512
- this._state = 'pending';
513
- this._map.on('mousemove', this._onMove);
514
- this._map.on('touchmove', this._onMove);
515
- this._map.once('mouseup', this._onUp);
516
- this._map.once('touchend', this._onUp);
517
- }
518
- }
519
-
520
- /**
521
- * Sets the `draggable` property and functionality of the marker
522
- * @param {boolean} [shouldBeDraggable=false] Turns drag functionality on/off
523
- * @returns {Marker} `this`
524
- */
525
- setDraggable(shouldBeDraggable: boolean) {
526
- this._draggable = !!shouldBeDraggable; // convert possible undefined value to false
527
-
528
- // handle case where map may not exist yet
529
- // e.g. when setDraggable is called before addTo
530
- if (this._map) {
531
- if (shouldBeDraggable) {
532
- this._map.on('mousedown', this._addDragHandler);
533
- this._map.on('touchstart', this._addDragHandler);
534
- } else {
535
- this._map.off('mousedown', this._addDragHandler);
536
- this._map.off('touchstart', this._addDragHandler);
537
- }
538
- }
539
-
540
- return this;
541
- }
542
-
543
- /**
544
- * Returns true if the marker can be dragged
545
- * @returns {boolean} True if the marker is draggable.
546
- */
547
- isDraggable() {
548
- return this._draggable;
549
- }
550
-
551
- /**
552
- * Sets the `rotation` property of the marker.
553
- * @param {number} [rotation=0] The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#rotationAlignment} setting.
554
- * @returns {Marker} `this`
555
- */
556
- setRotation(rotation: number) {
557
- this._rotation = rotation || 0;
558
- this._update();
559
- return this;
560
- }
561
-
562
- /**
563
- * Returns the current rotation angle of the marker (in degrees).
564
- * @returns {number} The current rotation angle of the marker.
565
- */
566
- getRotation() {
567
- return this._rotation;
568
- }
569
-
570
- /**
571
- * Sets the `rotationAlignment` property of the marker.
572
- * @param {string} [alignment='auto'] Sets the `rotationAlignment` property of the marker.
573
- * @returns {Marker} `this`
574
- */
575
- setRotationAlignment(alignment: string) {
576
- this._rotationAlignment = alignment || 'auto';
577
- this._update();
578
- return this;
579
- }
580
-
581
- /**
582
- * Returns the current `rotationAlignment` property of the marker.
583
- * @returns {string} The current rotational alignment of the marker.
584
- */
585
- getRotationAlignment() {
586
- return this._rotationAlignment;
587
- }
588
-
589
- /**
590
- * Sets the `pitchAlignment` property of the marker.
591
- * @param {string} [alignment] Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.
592
- * @returns {Marker} `this`
593
- */
594
- setPitchAlignment(alignment: string) {
595
- this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;
596
- this._update();
597
- return this;
598
- }
599
-
600
- /**
601
- * Returns the current `pitchAlignment` property of the marker.
602
- * @returns {string} The current pitch alignment of the marker in degrees.
603
- */
604
- getPitchAlignment() {
605
- return this._pitchAlignment;
606
- }
607
- }