@mapgis/mapbox-gl 16.0.1 → 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 (434) hide show
  1. package/dist/mapbox-gl.js +3 -3
  2. package/dist/mapbox-gl.js.map +1 -1
  3. package/package.json +1 -1
  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/flow-typed/gl.js +0 -5
  22. package/flow-typed/jsdom.js +0 -18
  23. package/flow-typed/mapbox-gl-supported.js +0 -9
  24. package/flow-typed/mapbox-unitbezier.js +0 -14
  25. package/flow-typed/offscreen-canvas.js +0 -9
  26. package/flow-typed/pbf.js +0 -25
  27. package/flow-typed/point-geometry.js +0 -44
  28. package/flow-typed/potpack.js +0 -12
  29. package/flow-typed/sinon.js +0 -28
  30. package/flow-typed/vector-tile.js +0 -41
  31. package/src/css/mapbox-gl.css +0 -798
  32. package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
  33. package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
  34. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
  35. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
  36. package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
  37. package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
  38. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
  39. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
  40. package/src/data/array_types.js +0 -1095
  41. package/src/data/bucket/circle_attributes.js +0 -9
  42. package/src/data/bucket/circle_bucket.js +0 -204
  43. package/src/data/bucket/fill_attributes.js +0 -9
  44. package/src/data/bucket/fill_bucket.js +0 -233
  45. package/src/data/bucket/fill_extrusion_attributes.js +0 -10
  46. package/src/data/bucket/fill_extrusion_bucket.js +0 -289
  47. package/src/data/bucket/heatmap_bucket.js +0 -17
  48. package/src/data/bucket/line_attributes.js +0 -10
  49. package/src/data/bucket/line_bucket.js +0 -556
  50. package/src/data/bucket/pattern_attributes.js +0 -10
  51. package/src/data/bucket/pattern_bucket_features.js +0 -60
  52. package/src/data/bucket/symbol_attributes.js +0 -117
  53. package/src/data/bucket/symbol_bucket.js +0 -972
  54. package/src/data/bucket.js +0 -123
  55. package/src/data/dem_data.js +0 -125
  56. package/src/data/extent.js +0 -18
  57. package/src/data/feature_index.js +0 -321
  58. package/src/data/feature_position_map.js +0 -125
  59. package/src/data/index_array_type.js +0 -16
  60. package/src/data/load_geometry.js +0 -48
  61. package/src/data/pos_attributes.js +0 -6
  62. package/src/data/program_configuration.js +0 -687
  63. package/src/data/raster_bounds_attributes.js +0 -7
  64. package/src/data/segment.js +0 -76
  65. package/src/geo/edge_insets.js +0 -102
  66. package/src/geo/lng_lat.js +0 -165
  67. package/src/geo/lng_lat_bounds.js +0 -267
  68. package/src/geo/mercator_coordinate.js +0 -153
  69. package/src/geo/transform.js +0 -864
  70. package/src/gl/color_mode.js +0 -34
  71. package/src/gl/context.js +0 -298
  72. package/src/gl/cull_face_mode.js +0 -26
  73. package/src/gl/depth_mode.js +0 -29
  74. package/src/gl/framebuffer.js +0 -44
  75. package/src/gl/index_buffer.js +0 -55
  76. package/src/gl/stencil_mode.js +0 -30
  77. package/src/gl/types.js +0 -84
  78. package/src/gl/value.js +0 -520
  79. package/src/gl/vertex_buffer.js +0 -119
  80. package/src/index.js +0 -201
  81. package/src/render/draw_background.js +0 -57
  82. package/src/render/draw_circle.js +0 -113
  83. package/src/render/draw_collision_debug.js +0 -49
  84. package/src/render/draw_custom.js +0 -49
  85. package/src/render/draw_debug.js +0 -127
  86. package/src/render/draw_fill.js +0 -126
  87. package/src/render/draw_fill_extrusion.js +0 -96
  88. package/src/render/draw_heatmap.js +0 -140
  89. package/src/render/draw_hillshade.js +0 -108
  90. package/src/render/draw_line.js +0 -98
  91. package/src/render/draw_raster.js +0 -125
  92. package/src/render/draw_symbol.js +0 -394
  93. package/src/render/glyph_atlas.js +0 -71
  94. package/src/render/glyph_manager.js +0 -182
  95. package/src/render/image_atlas.js +0 -149
  96. package/src/render/image_manager.js +0 -306
  97. package/src/render/line_atlas.js +0 -210
  98. package/src/render/painter.js +0 -653
  99. package/src/render/program/background_program.js +0 -103
  100. package/src/render/program/circle_program.js +0 -69
  101. package/src/render/program/clipping_mask_program.js +0 -20
  102. package/src/render/program/collision_program.js +0 -49
  103. package/src/render/program/debug_program.js +0 -35
  104. package/src/render/program/fill_extrusion_program.js +0 -122
  105. package/src/render/program/fill_program.js +0 -126
  106. package/src/render/program/heatmap_program.js +0 -83
  107. package/src/render/program/hillshade_program.js +0 -122
  108. package/src/render/program/line_program.js +0 -207
  109. package/src/render/program/pattern.js +0 -102
  110. package/src/render/program/program_uniforms.js +0 -42
  111. package/src/render/program/raster_program.js +0 -92
  112. package/src/render/program/symbol_program.js +0 -224
  113. package/src/render/program.js +0 -168
  114. package/src/render/texture.js +0 -122
  115. package/src/render/uniform_binding.js +0 -147
  116. package/src/render/vertex_array_object.js +0 -163
  117. package/src/shaders/README.md +0 -42
  118. package/src/shaders/_prelude.fragment.glsl +0 -17
  119. package/src/shaders/_prelude.vertex.glsl +0 -73
  120. package/src/shaders/background.fragment.glsl +0 -10
  121. package/src/shaders/background.vertex.glsl +0 -7
  122. package/src/shaders/background_pattern.fragment.glsl +0 -28
  123. package/src/shaders/background_pattern.vertex.glsl +0 -20
  124. package/src/shaders/circle.fragment.glsl +0 -39
  125. package/src/shaders/circle.vertex.glsl +0 -64
  126. package/src/shaders/clipping_mask.fragment.glsl +0 -3
  127. package/src/shaders/clipping_mask.vertex.glsl +0 -7
  128. package/src/shaders/collision_box.fragment.glsl +0 -21
  129. package/src/shaders/collision_box.vertex.glsl +0 -27
  130. package/src/shaders/collision_circle.fragment.glsl +0 -34
  131. package/src/shaders/collision_circle.vertex.glsl +0 -36
  132. package/src/shaders/debug.fragment.glsl +0 -9
  133. package/src/shaders/debug.vertex.glsl +0 -12
  134. package/src/shaders/encode_attribute.js +0 -17
  135. package/src/shaders/fill.fragment.glsl +0 -13
  136. package/src/shaders/fill.vertex.glsl +0 -13
  137. package/src/shaders/fill_extrusion.fragment.glsl +0 -9
  138. package/src/shaders/fill_extrusion.vertex.glsl +0 -66
  139. package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
  140. package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
  141. package/src/shaders/fill_outline.fragment.glsl +0 -17
  142. package/src/shaders/fill_outline.vertex.glsl +0 -17
  143. package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
  144. package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
  145. package/src/shaders/fill_pattern.fragment.glsl +0 -36
  146. package/src/shaders/fill_pattern.vertex.glsl +0 -39
  147. package/src/shaders/heatmap.fragment.glsl +0 -22
  148. package/src/shaders/heatmap.vertex.glsl +0 -54
  149. package/src/shaders/heatmap_texture.fragment.glsl +0 -14
  150. package/src/shaders/heatmap_texture.vertex.glsl +0 -11
  151. package/src/shaders/hillshade.fragment.glsl +0 -52
  152. package/src/shaders/hillshade.vertex.glsl +0 -11
  153. package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
  154. package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
  155. package/src/shaders/index.js +0 -20
  156. package/src/shaders/line.fragment.glsl +0 -30
  157. package/src/shaders/line.vertex.glsl +0 -85
  158. package/src/shaders/line_gradient.fragment.glsl +0 -34
  159. package/src/shaders/line_gradient.vertex.glsl +0 -87
  160. package/src/shaders/line_pattern.fragment.glsl +0 -74
  161. package/src/shaders/line_pattern.vertex.glsl +0 -99
  162. package/src/shaders/line_sdf.fragment.glsl +0 -45
  163. package/src/shaders/line_sdf.vertex.glsl +0 -98
  164. package/src/shaders/raster.fragment.glsl +0 -52
  165. package/src/shaders/raster.vertex.glsl +0 -21
  166. package/src/shaders/shaders.js +0 -180
  167. package/src/shaders/symbol_icon.fragment.glsl +0 -17
  168. package/src/shaders/symbol_icon.vertex.glsl +0 -94
  169. package/src/shaders/symbol_sdf.fragment.glsl +0 -52
  170. package/src/shaders/symbol_sdf.vertex.glsl +0 -115
  171. package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
  172. package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
  173. package/src/source/canvas_source.js +0 -238
  174. package/src/source/geojson_helper.js +0 -92
  175. package/src/source/geojson_source.js +0 -374
  176. package/src/source/geojson_worker_source.js +0 -357
  177. package/src/source/geojson_wrapper.js +0 -94
  178. package/src/source/image_source.js +0 -307
  179. package/src/source/load_tilejson.js +0 -39
  180. package/src/source/mbtiles_source.js +0 -115
  181. package/src/source/offline_database.js +0 -61
  182. package/src/source/offline_database_root.js +0 -62
  183. package/src/source/pixels_to_tile_units.js +0 -21
  184. package/src/source/query_features.js +0 -208
  185. package/src/source/raster_dem_tile_source.js +0 -138
  186. package/src/source/raster_dem_tile_worker_source.js +0 -62
  187. package/src/source/raster_tile_offline_source.js +0 -136
  188. package/src/source/raster_tile_source.js +0 -177
  189. package/src/source/rtl_text_plugin.js +0 -138
  190. package/src/source/source.js +0 -137
  191. package/src/source/source_cache.js +0 -957
  192. package/src/source/source_state.js +0 -159
  193. package/src/source/tile.js +0 -465
  194. package/src/source/tile_bounds.js +0 -38
  195. package/src/source/tile_cache.js +0 -212
  196. package/src/source/tile_id.js +0 -402
  197. package/src/source/vector_tile_source.js +0 -192
  198. package/src/source/vector_tile_worker_source.js +0 -216
  199. package/src/source/video_source.js +0 -203
  200. package/src/source/worker.js +0 -237
  201. package/src/source/worker_source.js +0 -106
  202. package/src/source/worker_tile.js +0 -224
  203. package/src/style/create_style_layer.js +0 -36
  204. package/src/style/evaluation_parameters.js +0 -62
  205. package/src/style/light.js +0 -130
  206. package/src/style/load_glyph_range.js +0 -38
  207. package/src/style/load_sprite.js +0 -67
  208. package/src/style/parse_glyph_pbf.js +0 -44
  209. package/src/style/pauseable_placement.js +0 -132
  210. package/src/style/properties.js +0 -753
  211. package/src/style/query_utils.js +0 -43
  212. package/src/style/style.js +0 -1361
  213. package/src/style/style_glyph.js +0 -17
  214. package/src/style/style_image.js +0 -137
  215. package/src/style/style_layer/background_style_layer.js +0 -21
  216. package/src/style/style_layer/background_style_layer_properties.js +0 -40
  217. package/src/style/style_layer/circle_style_layer.js +0 -98
  218. package/src/style/style_layer/circle_style_layer_properties.js +0 -63
  219. package/src/style/style_layer/custom_style_layer.js +0 -223
  220. package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
  221. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
  222. package/src/style/style_layer/fill_style_layer.js +0 -67
  223. package/src/style/style_layer/fill_style_layer_properties.js +0 -55
  224. package/src/style/style_layer/heatmap_style_layer.js +0 -69
  225. package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
  226. package/src/style/style_layer/hillshade_style_layer.js +0 -25
  227. package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
  228. package/src/style/style_layer/layer_properties.js.ejs +0 -69
  229. package/src/style/style_layer/line_style_layer.js +0 -151
  230. package/src/style/style_layer/line_style_layer_properties.js +0 -71
  231. package/src/style/style_layer/raster_style_layer.js +0 -21
  232. package/src/style/style_layer/raster_style_layer_properties.js +0 -50
  233. package/src/style/style_layer/symbol_style_layer.js +0 -190
  234. package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
  235. package/src/style/style_layer/typed_style_layer.js +0 -17
  236. package/src/style/style_layer.js +0 -281
  237. package/src/style/style_layer_index.js +0 -80
  238. package/src/style/validate_style.js +0 -42
  239. package/src/style/zoom_history.js +0 -44
  240. package/src/style-spec/.eslintrc +0 -5
  241. package/src/style-spec/CHANGELOG.md +0 -438
  242. package/src/style-spec/README.md +0 -59
  243. package/src/style-spec/bin/gl-style-composite +0 -9
  244. package/src/style-spec/bin/gl-style-format +0 -22
  245. package/src/style-spec/bin/gl-style-migrate +0 -9
  246. package/src/style-spec/bin/gl-style-validate +0 -50
  247. package/src/style-spec/composite.js +0 -50
  248. package/src/style-spec/declass.js +0 -42
  249. package/src/style-spec/deref.js +0 -52
  250. package/src/style-spec/diff.js +0 -393
  251. package/src/style-spec/dist/.gitkeep +0 -0
  252. package/src/style-spec/empty.js +0 -29
  253. package/src/style-spec/error/parsing_error.js +0 -16
  254. package/src/style-spec/error/validation_error.js +0 -18
  255. package/src/style-spec/expression/compound_expression.js +0 -162
  256. package/src/style-spec/expression/definitions/assertion.js +0 -130
  257. package/src/style-spec/expression/definitions/at.js +0 -70
  258. package/src/style-spec/expression/definitions/case.js +0 -85
  259. package/src/style-spec/expression/definitions/coalesce.js +0 -93
  260. package/src/style-spec/expression/definitions/coercion.js +0 -133
  261. package/src/style-spec/expression/definitions/collator.js +0 -78
  262. package/src/style-spec/expression/definitions/comparison.js +0 -184
  263. package/src/style-spec/expression/definitions/format.js +0 -144
  264. package/src/style-spec/expression/definitions/format_section_override.js +0 -54
  265. package/src/style-spec/expression/definitions/image.js +0 -52
  266. package/src/style-spec/expression/definitions/in.js +0 -92
  267. package/src/style-spec/expression/definitions/index.js +0 -561
  268. package/src/style-spec/expression/definitions/interpolate.js +0 -267
  269. package/src/style-spec/expression/definitions/length.js +0 -61
  270. package/src/style-spec/expression/definitions/let.js +0 -72
  271. package/src/style-spec/expression/definitions/literal.js +0 -77
  272. package/src/style-spec/expression/definitions/match.js +0 -158
  273. package/src/style-spec/expression/definitions/number_format.js +0 -142
  274. package/src/style-spec/expression/definitions/step.js +0 -120
  275. package/src/style-spec/expression/definitions/var.js +0 -46
  276. package/src/style-spec/expression/definitions/within.js +0 -333
  277. package/src/style-spec/expression/evaluation_context.js +0 -59
  278. package/src/style-spec/expression/expression.js +0 -27
  279. package/src/style-spec/expression/index.js +0 -392
  280. package/src/style-spec/expression/is_constant.js +0 -59
  281. package/src/style-spec/expression/parsing_context.js +0 -233
  282. package/src/style-spec/expression/parsing_error.js +0 -13
  283. package/src/style-spec/expression/runtime_error.js +0 -17
  284. package/src/style-spec/expression/scope.js +0 -36
  285. package/src/style-spec/expression/stops.js +0 -39
  286. package/src/style-spec/expression/types/collator.js +0 -61
  287. package/src/style-spec/expression/types/formatted.js +0 -73
  288. package/src/style-spec/expression/types/resolved_image.js +0 -29
  289. package/src/style-spec/expression/types.js +0 -106
  290. package/src/style-spec/expression/values.js +0 -123
  291. package/src/style-spec/feature_filter/README.md +0 -55
  292. package/src/style-spec/feature_filter/convert.js +0 -208
  293. package/src/style-spec/feature_filter/index.js +0 -165
  294. package/src/style-spec/format.js +0 -51
  295. package/src/style-spec/function/convert.js +0 -254
  296. package/src/style-spec/function/index.js +0 -262
  297. package/src/style-spec/group_by_layout.js +0 -75
  298. package/src/style-spec/migrate/expressions.js +0 -39
  299. package/src/style-spec/migrate/v8.js +0 -203
  300. package/src/style-spec/migrate/v9.js +0 -26
  301. package/src/style-spec/migrate.js +0 -36
  302. package/src/style-spec/package.json +0 -41
  303. package/src/style-spec/read_style.js +0 -14
  304. package/src/style-spec/reference/latest.js +0 -3
  305. package/src/style-spec/reference/v8.json +0 -5808
  306. package/src/style-spec/rollup.config.js +0 -45
  307. package/src/style-spec/style-spec.js +0 -122
  308. package/src/style-spec/types.js +0 -438
  309. package/src/style-spec/util/color.js +0 -95
  310. package/src/style-spec/util/color_spaces.js +0 -139
  311. package/src/style-spec/util/deep_equal.js +0 -28
  312. package/src/style-spec/util/extend.js +0 -10
  313. package/src/style-spec/util/get_type.js +0 -17
  314. package/src/style-spec/util/interpolate.js +0 -22
  315. package/src/style-spec/util/properties.js +0 -15
  316. package/src/style-spec/util/ref_properties.js +0 -2
  317. package/src/style-spec/util/result.js +0 -19
  318. package/src/style-spec/util/unbundle_jsonlint.js +0 -24
  319. package/src/style-spec/validate/latest.js +0 -11
  320. package/src/style-spec/validate/validate.js +0 -75
  321. package/src/style-spec/validate/validate_array.js +0 -52
  322. package/src/style-spec/validate/validate_boolean.js +0 -15
  323. package/src/style-spec/validate/validate_color.js +0 -20
  324. package/src/style-spec/validate/validate_constants.js +0 -13
  325. package/src/style-spec/validate/validate_enum.js +0 -21
  326. package/src/style-spec/validate/validate_expression.js +0 -43
  327. package/src/style-spec/validate/validate_filter.js +0 -111
  328. package/src/style-spec/validate/validate_formatted.js +0 -11
  329. package/src/style-spec/validate/validate_function.js +0 -207
  330. package/src/style-spec/validate/validate_glyphs_url.js +0 -21
  331. package/src/style-spec/validate/validate_image.js +0 -11
  332. package/src/style-spec/validate/validate_layer.js +0 -134
  333. package/src/style-spec/validate/validate_layout_property.js +0 -6
  334. package/src/style-spec/validate/validate_light.js +0 -47
  335. package/src/style-spec/validate/validate_number.js +0 -29
  336. package/src/style-spec/validate/validate_object.js +0 -61
  337. package/src/style-spec/validate/validate_paint_property.js +0 -6
  338. package/src/style-spec/validate/validate_property.js +0 -64
  339. package/src/style-spec/validate/validate_source.js +0 -111
  340. package/src/style-spec/validate/validate_string.js +0 -15
  341. package/src/style-spec/validate_mapbox_api_supported.js +0 -171
  342. package/src/style-spec/validate_style.js +0 -39
  343. package/src/style-spec/validate_style.min.js +0 -78
  344. package/src/style-spec/visit.js +0 -77
  345. package/src/symbol/anchor.js +0 -26
  346. package/src/symbol/check_max_angle.js +0 -81
  347. package/src/symbol/clip_line.js +0 -71
  348. package/src/symbol/collision_feature.js +0 -217
  349. package/src/symbol/collision_index.js +0 -372
  350. package/src/symbol/cross_tile_symbol_index.js +0 -301
  351. package/src/symbol/get_anchors.js +0 -167
  352. package/src/symbol/grid_index.js +0 -335
  353. package/src/symbol/mergelines.js +0 -82
  354. package/src/symbol/one_em.js +0 -4
  355. package/src/symbol/opacity_state.js +0 -27
  356. package/src/symbol/placement.js +0 -1062
  357. package/src/symbol/projection.js +0 -450
  358. package/src/symbol/quads.js +0 -334
  359. package/src/symbol/shaping.js +0 -816
  360. package/src/symbol/symbol_layout.js +0 -772
  361. package/src/symbol/symbol_size.js +0 -113
  362. package/src/symbol/transform_text.js +0 -29
  363. package/src/types/callback.js +0 -17
  364. package/src/types/cancelable.js +0 -3
  365. package/src/types/tilejson.js +0 -17
  366. package/src/types/transferable.js +0 -3
  367. package/src/types/window.js +0 -172
  368. package/src/ui/anchor.js +0 -32
  369. package/src/ui/bind_handlers.js +0 -202
  370. package/src/ui/camera.js +0 -1152
  371. package/src/ui/control/attribution_control.js +0 -189
  372. package/src/ui/control/fps_control.js +0 -185
  373. package/src/ui/control/fullscreen_control.js +0 -147
  374. package/src/ui/control/geolocate_control.js +0 -594
  375. package/src/ui/control/logo_control.js +0 -92
  376. package/src/ui/control/navigation_control.js +0 -148
  377. package/src/ui/control/scale_control.js +0 -142
  378. package/src/ui/crs.js +0 -64
  379. package/src/ui/default_locale.js +0 -20
  380. package/src/ui/events.js +0 -806
  381. package/src/ui/handler/box_zoom.js +0 -175
  382. package/src/ui/handler/dblclick_zoom.js +0 -139
  383. package/src/ui/handler/drag_pan.js +0 -416
  384. package/src/ui/handler/drag_rotate.js +0 -378
  385. package/src/ui/handler/keyboard.js +0 -161
  386. package/src/ui/handler/scroll_zoom.js +0 -333
  387. package/src/ui/handler/touch_zoom_rotate.js +0 -293
  388. package/src/ui/hash.js +0 -147
  389. package/src/ui/map.js +0 -2883
  390. package/src/ui/marker.js +0 -607
  391. package/src/ui/offline_map.js +0 -91
  392. package/src/ui/popup.js +0 -530
  393. package/src/util/actor.js +0 -212
  394. package/src/util/ajax.js +0 -371
  395. package/src/util/browser/web_worker.js +0 -10
  396. package/src/util/browser/window.js +0 -5
  397. package/src/util/browser.js +0 -70
  398. package/src/util/classify_rings.js +0 -52
  399. package/src/util/color_ramp.js +0 -28
  400. package/src/util/config.js +0 -30
  401. package/src/util/debug.js +0 -12
  402. package/src/util/dictionary_coder.js +0 -30
  403. package/src/util/dispatcher.js +0 -70
  404. package/src/util/dom.js +0 -144
  405. package/src/util/evented.js +0 -174
  406. package/src/util/find_pole_of_inaccessibility.js +0 -129
  407. package/src/util/global_worker_pool.js +0 -17
  408. package/src/util/image.js +0 -142
  409. package/src/util/intersection_tests.js +0 -208
  410. package/src/util/is_char_in_unicode_block.js +0 -311
  411. package/src/util/mapbox.js +0 -486
  412. package/src/util/offscreen_canvas_supported.js +0 -14
  413. package/src/util/performance.js +0 -112
  414. package/src/util/primitives.js +0 -145
  415. package/src/util/resolve_tokens.js +0 -16
  416. package/src/util/script_detection.js +0 -328
  417. package/src/util/sku_token.js +0 -42
  418. package/src/util/smart_wrap.js +0 -55
  419. package/src/util/struct_array.js +0 -243
  420. package/src/util/struct_array.js.ejs +0 -112
  421. package/src/util/struct_array_layout.js.ejs +0 -98
  422. package/src/util/task_queue.js +0 -68
  423. package/src/util/throttle.js +0 -28
  424. package/src/util/throttled_invoker.js +0 -46
  425. package/src/util/tile_cover.js +0 -101
  426. package/src/util/tile_request_cache.js +0 -172
  427. package/src/util/util.js +0 -504
  428. package/src/util/vectortile_to_geojson.js +0 -54
  429. package/src/util/verticalize_punctuation.js +0 -114
  430. package/src/util/web_worker.js +0 -91
  431. package/src/util/web_worker_transfer.js +0 -266
  432. package/src/util/webp_supported.js +0 -69
  433. package/src/util/window.js +0 -102
  434. package/src/util/worker_pool.js +0 -47
@@ -1,1361 +0,0 @@
1
- // @flow
2
-
3
- import assert from 'assert';
4
-
5
- import {Event, ErrorEvent, Evented} from '../util/evented';
6
- import StyleLayer from './style_layer';
7
- import createStyleLayer from './create_style_layer';
8
- import loadSprite from './load_sprite';
9
- import ImageManager from '../render/image_manager';
10
- import GlyphManager from '../render/glyph_manager';
11
- import Light from './light';
12
- import LineAtlas from '../render/line_atlas';
13
- import {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util';
14
- import {getJSON, getReferrer, makeRequest, ResourceType} from '../util/ajax';
15
- import {isMapboxURL} from '../util/mapbox';
16
- import browser from '../util/browser';
17
- import Dispatcher from '../util/dispatcher';
18
- import {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style';
19
- import {
20
- getType as getSourceType,
21
- setType as setSourceType,
22
- type SourceClass
23
- } from '../source/source';
24
- import {queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features';
25
- import SourceCache from '../source/source_cache';
26
- import GeoJSONSource from '../source/geojson_source';
27
- import styleSpec from '../style-spec/reference/latest';
28
- import getWorkerPool from '../util/global_worker_pool';
29
- import deref from '../style-spec/deref';
30
- import emptyStyle from '../style-spec/empty';
31
- import diffStyles, {operations as diffOperations} from '../style-spec/diff';
32
- import {
33
- registerForPluginStateChange,
34
- evented as rtlTextPluginEvented,
35
- triggerPluginCompletionEvent
36
- } from '../source/rtl_text_plugin';
37
- import PauseablePlacement from './pauseable_placement';
38
- import ZoomHistory from './zoom_history';
39
- import CrossTileSymbolIndex from '../symbol/cross_tile_symbol_index';
40
- import {validateCustomStyleLayer} from './style_layer/custom_style_layer';
41
-
42
- // We're skipping validation errors with the `source.canvas` identifier in order
43
- // to continue to allow canvas sources to be added at runtime/updated in
44
- // smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424):
45
- const emitValidationErrors = (evented: Evented, errors: ?$ReadOnlyArray<{message: string, identifier?: string}>) =>
46
- _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas'));
47
-
48
- import type Map from '../ui/map';
49
- import type Transform from '../geo/transform';
50
- import type {StyleImage} from './style_image';
51
- import type {StyleGlyph} from './style_glyph';
52
- import type {Callback} from '../types/callback';
53
- import type EvaluationParameters from './evaluation_parameters';
54
- import type {Placement} from '../symbol/placement';
55
- import type {Cancelable} from '../types/cancelable';
56
- import type {RequestParameters, ResponseCallback} from '../util/ajax';
57
- import type {GeoJSON} from '@mapbox/geojson-types';
58
- import type {
59
- LayerSpecification,
60
- FilterSpecification,
61
- StyleSpecification,
62
- LightSpecification,
63
- SourceSpecification
64
- } from '../style-spec/types';
65
- import type {CustomLayerInterface} from './style_layer/custom_style_layer';
66
- import type {Validator} from './validate_style';
67
- import type {OverscaledTileID} from '../source/tile_id';
68
-
69
- const supportedDiffOperations = pick(diffOperations, [
70
- 'addLayer',
71
- 'removeLayer',
72
- 'setPaintProperty',
73
- 'setLayoutProperty',
74
- 'setFilter',
75
- 'addSource',
76
- 'removeSource',
77
- 'setLayerZoomRange',
78
- 'setLight',
79
- 'setTransition',
80
- 'setGeoJSONSourceData'
81
- // 'setGlyphs',
82
- // 'setSprite',
83
- ]);
84
-
85
- const ignoredDiffOperations = pick(diffOperations, [
86
- 'setCenter',
87
- 'setZoom',
88
- 'setBearing',
89
- 'setPitch'
90
- ]);
91
-
92
- const empty = emptyStyle();
93
-
94
- export type StyleOptions = {
95
- validate?: boolean,
96
- localIdeographFontFamily?: string
97
- };
98
-
99
- export type StyleSetterOptions = {
100
- validate?: boolean
101
- };
102
- /**
103
- * @private
104
- */
105
- class Style extends Evented {
106
- map: Map;
107
- stylesheet: StyleSpecification;
108
- dispatcher: Dispatcher;
109
- imageManager: ImageManager;
110
- glyphManager: GlyphManager;
111
- lineAtlas: LineAtlas;
112
- light: Light;
113
-
114
- _request: ?Cancelable;
115
- _spriteRequest: ?Cancelable;
116
- _layers: {[_: string]: StyleLayer};
117
- _serializedLayers: {[_: string]: Object};
118
- _order: Array<string>;
119
- sourceCaches: {[_: string]: SourceCache};
120
- zoomHistory: ZoomHistory;
121
- _loaded: boolean;
122
- _rtlTextPluginCallback: Function;
123
- _changed: boolean;
124
- _updatedSources: {[_: string]: 'clear' | 'reload'};
125
- _updatedLayers: {[_: string]: true};
126
- _removedLayers: {[_: string]: StyleLayer};
127
- _changedImages: {[_: string]: true};
128
- _updatedPaintProps: {[layer: string]: true};
129
- _layerOrderChanged: boolean;
130
- _availableImages: Array<string>;
131
-
132
- crossTileSymbolIndex: CrossTileSymbolIndex;
133
- pauseablePlacement: PauseablePlacement;
134
- placement: Placement;
135
- z: number;
136
-
137
- // exposed to allow stubbing by unit tests
138
- static getSourceType: typeof getSourceType;
139
- static setSourceType: typeof setSourceType;
140
- static registerForPluginStateChange: typeof registerForPluginStateChange;
141
-
142
- constructor(map: Map, options: StyleOptions = {}) {
143
- super();
144
-
145
- this.map = map;
146
- this.dispatcher = new Dispatcher(getWorkerPool(), this);
147
- this.imageManager = new ImageManager();
148
- this.imageManager.setEventedParent(this);
149
- this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily);
150
- this.lineAtlas = new LineAtlas(256, 512);
151
- this.crossTileSymbolIndex = new CrossTileSymbolIndex();
152
-
153
- this._layers = {};
154
- this._serializedLayers = {};
155
- this._order = [];
156
- this.sourceCaches = {};
157
- this.zoomHistory = new ZoomHistory();
158
- this._loaded = false;
159
- this._availableImages = [];
160
-
161
- this._resetUpdates();
162
-
163
- this.dispatcher.broadcast('setReferrer', getReferrer());
164
-
165
- const self = this;
166
- this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => {
167
- const state = {
168
- pluginStatus: event.pluginStatus,
169
- pluginURL: event.pluginURL
170
- };
171
- self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => {
172
- triggerPluginCompletionEvent(err);
173
- if (results) {
174
- const allComplete = results.every((elem) => elem);
175
- if (allComplete) {
176
- for (const id in self.sourceCaches) {
177
- self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load
178
- }
179
- }
180
- }
181
-
182
- });
183
- });
184
-
185
- this.on('data', (event) => {
186
- if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') {
187
- return;
188
- }
189
-
190
- const sourceCache = this.sourceCaches[event.sourceId];
191
- if (!sourceCache) {
192
- return;
193
- }
194
-
195
- const source = sourceCache.getSource();
196
- if (!source || !source.vectorLayerIds) {
197
- return;
198
- }
199
-
200
- for (const layerId in this._layers) {
201
- const layer = this._layers[layerId];
202
- if (layer.source === source.id) {
203
- this._validateLayer(layer);
204
- }
205
- }
206
- });
207
- }
208
-
209
- loadURL(url: string, options: {
210
- validate?: boolean,
211
- accessToken?: string
212
- } = {}) {
213
- this.fire(new Event('dataloading', {dataType: 'style'}));
214
-
215
- const validate = typeof options.validate === 'boolean' ?
216
- options.validate : !isMapboxURL(url);
217
-
218
- url = this.map._requestManager.normalizeStyleURL(url, options.accessToken);
219
- const request = this.map._requestManager.transformRequest(url, ResourceType.Style);
220
- this._request = getJSON(request, (error: ?Error, json: ?Object) => {
221
- this._request = null;
222
- if (error) {
223
- this.fire(new ErrorEvent(error));
224
- } else if (json) {
225
- this._load(json, validate);
226
- }
227
- });
228
- }
229
-
230
- loadJSON(json: StyleSpecification, options: StyleSetterOptions = {}) {
231
- this.fire(new Event('dataloading', {dataType: 'style'}));
232
-
233
- this._request = browser.frame(() => {
234
- this._request = null;
235
- this._load(json, options.validate !== false);
236
- });
237
- }
238
-
239
- loadEmpty() {
240
- this.fire(new Event('dataloading', {dataType: 'style'}));
241
- this._load(empty, false);
242
- }
243
-
244
- _load(json: StyleSpecification, validate: boolean) {
245
- if (validate && emitValidationErrors(this, validateStyle(json))) {
246
- return;
247
- }
248
-
249
- this._loaded = true;
250
- this.stylesheet = json;
251
-
252
- for (const id in json.sources) {
253
- this.addSource(id, json.sources[id], {validate: false});
254
- }
255
-
256
- if (json.sprite) {
257
- this._loadSprite(json.sprite);
258
- } else {
259
- this.imageManager.setLoaded(true);
260
- }
261
-
262
- this.glyphManager.setURL(json.glyphs);
263
-
264
- const layers = deref(this.stylesheet.layers);
265
-
266
- this._order = layers.map((layer) => layer.id);
267
-
268
- this._layers = {};
269
- this._serializedLayers = {};
270
- for (let layer of layers) {
271
- layer = createStyleLayer(layer);
272
- layer.setEventedParent(this, {layer: {id: layer.id}});
273
- this._layers[layer.id] = layer;
274
- this._serializedLayers[layer.id] = layer.serialize();
275
- }
276
- this.dispatcher.broadcast('setLayers', this._serializeLayers(this._order));
277
-
278
- this.light = new Light(this.stylesheet.light);
279
-
280
- this.fire(new Event('data', {dataType: 'style'}));
281
- this.fire(new Event('style.load'));
282
- }
283
-
284
- _loadSprite(url: string) {
285
- this._spriteRequest = loadSprite(url, this.map._requestManager, (err, images) => {
286
- this._spriteRequest = null;
287
- if (err) {
288
- this.fire(new ErrorEvent(err));
289
- } else if (images) {
290
- for (const id in images) {
291
- this.imageManager.addImage(id, images[id]);
292
- }
293
- }
294
-
295
- this.imageManager.setLoaded(true);
296
- this._availableImages = this.imageManager.listImages();
297
- this.dispatcher.broadcast('setImages', this._availableImages);
298
- this.fire(new Event('data', {dataType: 'style'}));
299
- });
300
- }
301
-
302
- _validateLayer(layer: StyleLayer) {
303
- const sourceCache = this.sourceCaches[layer.source];
304
- if (!sourceCache) {
305
- return;
306
- }
307
-
308
- const sourceLayer = layer.sourceLayer;
309
- if (!sourceLayer) {
310
- return;
311
- }
312
-
313
- const source = sourceCache.getSource();
314
- if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) {
315
- this.fire(new ErrorEvent(new Error(
316
- `Source layer "${sourceLayer}" ` +
317
- `does not exist on source "${source.id}" ` +
318
- `as specified by style layer "${layer.id}"`
319
- )));
320
- }
321
- }
322
-
323
- loaded() {
324
- if (!this._loaded)
325
- return false;
326
-
327
- if (Object.keys(this._updatedSources).length)
328
- return false;
329
-
330
- for (const id in this.sourceCaches)
331
- if (!this.sourceCaches[id].loaded())
332
- return false;
333
-
334
- if (!this.imageManager.isLoaded())
335
- return false;
336
-
337
- return true;
338
- }
339
-
340
- _serializeLayers(ids: Array<string>): Array<Object> {
341
- const serializedLayers = [];
342
- for (const id of ids) {
343
- const layer = this._layers[id];
344
- if (layer.type !== 'custom') {
345
- serializedLayers.push(layer.serialize());
346
- }
347
- }
348
- return serializedLayers;
349
- }
350
-
351
- hasTransitions() {
352
- if (this.light && this.light.hasTransition()) {
353
- return true;
354
- }
355
-
356
- for (const id in this.sourceCaches) {
357
- if (this.sourceCaches[id].hasTransition()) {
358
- return true;
359
- }
360
- }
361
-
362
- for (const id in this._layers) {
363
- if (this._layers[id].hasTransition()) {
364
- return true;
365
- }
366
- }
367
-
368
- return false;
369
- }
370
-
371
- _checkLoaded() {
372
- if (!this._loaded) {
373
- throw new Error('Style is not done loading');
374
- }
375
- }
376
-
377
- /**
378
- * Apply queued style updates in a batch and recalculate zoom-dependent paint properties.
379
- * @private
380
- */
381
- update(parameters: EvaluationParameters) {
382
- if (!this._loaded) {
383
- return;
384
- }
385
-
386
- const changed = this._changed;
387
- if (this._changed) {
388
- const updatedIds = Object.keys(this._updatedLayers);
389
- const removedIds = Object.keys(this._removedLayers);
390
-
391
- if (updatedIds.length || removedIds.length) {
392
- this._updateWorkerLayers(updatedIds, removedIds);
393
- }
394
- for (const id in this._updatedSources) {
395
- const action = this._updatedSources[id];
396
- assert(action === 'reload' || action === 'clear');
397
- if (action === 'reload') {
398
- this._reloadSource(id);
399
- } else if (action === 'clear') {
400
- this._clearSource(id);
401
- }
402
- }
403
-
404
- this._updateTilesForChangedImages();
405
-
406
- for (const id in this._updatedPaintProps) {
407
- this._layers[id].updateTransitions(parameters);
408
- }
409
-
410
- this.light.updateTransitions(parameters);
411
-
412
- this._resetUpdates();
413
- }
414
-
415
- for (const sourceId in this.sourceCaches) {
416
- this.sourceCaches[sourceId].used = false;
417
- }
418
-
419
- for (const layerId of this._order) {
420
- const layer = this._layers[layerId];
421
-
422
- layer.recalculate(parameters, this._availableImages);
423
- if (!layer.isHidden(parameters.zoom) && layer.source) {
424
- this.sourceCaches[layer.source].used = true;
425
- }
426
- }
427
-
428
- this.light.recalculate(parameters);
429
- this.z = parameters.zoom;
430
-
431
- if (changed) {
432
- this.fire(new Event('data', {dataType: 'style'}));
433
- }
434
-
435
- }
436
-
437
- /*
438
- * Apply any queued image changes.
439
- */
440
- _updateTilesForChangedImages() {
441
- const changedImages = Object.keys(this._changedImages);
442
- if (changedImages.length) {
443
- for (const name in this.sourceCaches) {
444
- this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages);
445
- }
446
- this._changedImages = {};
447
- }
448
- }
449
-
450
- _updateWorkerLayers(updatedIds: Array<string>, removedIds: Array<string>) {
451
- this.dispatcher.broadcast('updateLayers', {
452
- layers: this._serializeLayers(updatedIds),
453
- removedIds
454
- });
455
- }
456
-
457
- _resetUpdates() {
458
- this._changed = false;
459
-
460
- this._updatedLayers = {};
461
- this._removedLayers = {};
462
-
463
- this._updatedSources = {};
464
- this._updatedPaintProps = {};
465
-
466
- this._changedImages = {};
467
- }
468
-
469
- /**
470
- * Update this style's state to match the given style JSON, performing only
471
- * the necessary mutations.
472
- *
473
- * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec
474
- * diff algorithm produces an operation that is not supported.
475
- *
476
- * @returns {boolean} true if any changes were made; false otherwise
477
- * @private
478
- */
479
- setState(nextState: StyleSpecification) {
480
- this._checkLoaded();
481
-
482
- if (emitValidationErrors(this, validateStyle(nextState))) return false;
483
-
484
- nextState = clone(nextState);
485
- nextState.layers = deref(nextState.layers);
486
-
487
- const changes = diffStyles(this.serialize(), nextState)
488
- .filter(op => !(op.command in ignoredDiffOperations));
489
-
490
- if (changes.length === 0) {
491
- return false;
492
- }
493
-
494
- const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations));
495
- if (unimplementedOps.length > 0) {
496
- throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`);
497
- }
498
-
499
- changes.forEach((op) => {
500
- if (op.command === 'setTransition') {
501
- // `transition` is always read directly off of
502
- // `this.stylesheet`, which we update below
503
- return;
504
- }
505
- (this: any)[op.command].apply(this, op.args);
506
- });
507
-
508
- this.stylesheet = nextState;
509
-
510
- return true;
511
- }
512
-
513
- addImage(id: string, image: StyleImage) {
514
- if (this.getImage(id)) {
515
- return this.fire(new ErrorEvent(new Error('An image with this name already exists.')));
516
- }
517
- this.imageManager.addImage(id, image);
518
- this._availableImages = this.imageManager.listImages();
519
- this._changedImages[id] = true;
520
- this._changed = true;
521
- this.fire(new Event('data', {dataType: 'style'}));
522
- }
523
-
524
- updateImage(id: string, image: StyleImage) {
525
- this.imageManager.updateImage(id, image);
526
- }
527
-
528
- getImage(id: string): ?StyleImage {
529
- return this.imageManager.getImage(id);
530
- }
531
-
532
- removeImage(id: string) {
533
- if (!this.getImage(id)) {
534
- return this.fire(new ErrorEvent(new Error('No image with this name exists.')));
535
- }
536
- this.imageManager.removeImage(id);
537
- this._availableImages = this.imageManager.listImages();
538
- this._changedImages[id] = true;
539
- this._changed = true;
540
- this.fire(new Event('data', {dataType: 'style'}));
541
- }
542
-
543
- listImages() {
544
- this._checkLoaded();
545
-
546
- return this.imageManager.listImages();
547
- }
548
-
549
- addSource(id: string, source: SourceSpecification, options: StyleSetterOptions = {}) {
550
- this._checkLoaded();
551
-
552
- if (this.sourceCaches[id] !== undefined) {
553
- throw new Error('There is already a source with this ID');
554
- }
555
-
556
- if (!source.type) {
557
- throw new Error(`The type property must be defined, but the only the following properties were given: ${Object.keys(source).join(', ')}.`);
558
- }
559
-
560
- const builtIns = ['vector', 'raster', 'geojson', 'video', 'image'];
561
- const shouldValidate = builtIns.indexOf(source.type) >= 0;
562
- if (shouldValidate && this._validate(validateStyle.source, `sources.${id}`, source, null, options)) return;
563
-
564
- if (this.map && this.map._collectResourceTiming) (source: any).collectResourceTiming = true;
565
- const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher);
566
- sourceCache.style = this;
567
- sourceCache.setEventedParent(this, () => ({
568
- isSourceLoaded: this.loaded(),
569
- source: sourceCache.serialize(),
570
- sourceId: id
571
- }));
572
-
573
- sourceCache.onAdd(this.map);
574
- this._changed = true;
575
- }
576
-
577
- /**
578
- * Remove a source from this stylesheet, given its id.
579
- * @param {string} id id of the source to remove
580
- * @throws {Error} if no source is found with the given ID
581
- * @returns {Map} The {@link Map} object.
582
- */
583
- removeSource(id: string) {
584
- this._checkLoaded();
585
-
586
- if (this.sourceCaches[id] === undefined) {
587
- throw new Error('There is no source with this ID');
588
- }
589
- for (const layerId in this._layers) {
590
- if (this._layers[layerId].source === id) {
591
- return this.fire(new ErrorEvent(new Error(`Source "${id}" cannot be removed while layer "${layerId}" is using it.`)));
592
- }
593
- }
594
-
595
- const sourceCache = this.sourceCaches[id];
596
- delete this.sourceCaches[id];
597
- delete this._updatedSources[id];
598
- sourceCache.fire(new Event('data', {sourceDataType: 'metadata', dataType:'source', sourceId: id}));
599
- sourceCache.setEventedParent(null);
600
- sourceCache.clearTiles();
601
-
602
- if (sourceCache.onRemove) sourceCache.onRemove(this.map);
603
- this._changed = true;
604
- }
605
-
606
- /**
607
- * Set the data of a GeoJSON source, given its id.
608
- * @param {string} id id of the source
609
- * @param {GeoJSON|string} data GeoJSON source
610
- */
611
- setGeoJSONSourceData(id: string, data: GeoJSON | string) {
612
- this._checkLoaded();
613
-
614
- assert(this.sourceCaches[id] !== undefined, 'There is no source with this ID');
615
- const geojsonSource: GeoJSONSource = (this.sourceCaches[id].getSource(): any);
616
- assert(geojsonSource.type === 'geojson');
617
-
618
- geojsonSource.setData(data);
619
- this._changed = true;
620
- }
621
-
622
- /**
623
- * Get a source by id.
624
- * @param {string} id id of the desired source
625
- * @returns {Object} source
626
- */
627
- getSource(id: string): Object {
628
- return this.sourceCaches[id] && this.sourceCaches[id].getSource();
629
- }
630
-
631
- /**
632
- * Add a layer to the map style. The layer will be inserted before the layer with
633
- * ID `before`, or appended if `before` is omitted.
634
- * @param {Object | CustomLayerInterface} layerObject The style layer to add.
635
- * @param {string} [before] ID of an existing layer to insert before
636
- * @param {Object} options Style setter options.
637
- * @returns {Map} The {@link Map} object.
638
- */
639
- addLayer(layerObject: LayerSpecification | CustomLayerInterface, before?: string, options: StyleSetterOptions = {}) {
640
- this._checkLoaded();
641
-
642
- const id = layerObject.id;
643
-
644
- if (this.getLayer(id)) {
645
- this.fire(new ErrorEvent(new Error(`Layer with id "${id}" already exists on this map`)));
646
- return;
647
- }
648
-
649
- let layer;
650
- if (layerObject.type === 'custom') {
651
-
652
- if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return;
653
-
654
- layer = createStyleLayer(layerObject);
655
-
656
- } else {
657
- if (typeof layerObject.source === 'object') {
658
- this.addSource(id, layerObject.source);
659
- layerObject = clone(layerObject);
660
- layerObject = (extend(layerObject, {source: id}): any);
661
- }
662
-
663
- // this layer is not in the style.layers array, so we pass an impossible array index
664
- if (this._validate(validateStyle.layer,
665
- `layers.${id}`, layerObject, {arrayIndex: -1}, options)) return;
666
-
667
- layer = createStyleLayer(layerObject);
668
- this._validateLayer(layer);
669
-
670
- layer.setEventedParent(this, {layer: {id}});
671
- this._serializedLayers[layer.id] = layer.serialize();
672
- }
673
-
674
- const index = before ? this._order.indexOf(before) : this._order.length;
675
- if (before && index === -1) {
676
- this.fire(new ErrorEvent(new Error(`Layer with id "${before}" does not exist on this map.`)));
677
- return;
678
- }
679
-
680
- this._order.splice(index, 0, id);
681
- this._layerOrderChanged = true;
682
-
683
- this._layers[id] = layer;
684
-
685
- if (this._removedLayers[id] && layer.source && layer.type !== 'custom') {
686
- // If, in the current batch, we have already removed this layer
687
- // and we are now re-adding it with a different `type`, then we
688
- // need to clear (rather than just reload) the underyling source's
689
- // tiles. Otherwise, tiles marked 'reloading' will have buckets /
690
- // buffers that are set up for the _previous_ version of this
691
- // layer, causing, e.g.:
692
- // https://github.com/mapbox/mapbox-gl-js/issues/3633
693
- const removed = this._removedLayers[id];
694
- delete this._removedLayers[id];
695
- if (removed.type !== layer.type) {
696
- this._updatedSources[layer.source] = 'clear';
697
- } else {
698
- this._updatedSources[layer.source] = 'reload';
699
- this.sourceCaches[layer.source].pause();
700
- }
701
- }
702
- this._updateLayer(layer);
703
-
704
- if (layer.onAdd) {
705
- layer.onAdd(this.map);
706
- }
707
- }
708
-
709
- /**
710
- * Moves a layer to a different z-position. The layer will be inserted before the layer with
711
- * ID `before`, or appended if `before` is omitted.
712
- * @param {string} id ID of the layer to move
713
- * @param {string} [before] ID of an existing layer to insert before
714
- */
715
- moveLayer(id: string, before?: string) {
716
- this._checkLoaded();
717
- this._changed = true;
718
-
719
- const layer = this._layers[id];
720
- if (!layer) {
721
- this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`)));
722
- return;
723
- }
724
-
725
- if (id === before) {
726
- return;
727
- }
728
-
729
- const index = this._order.indexOf(id);
730
- this._order.splice(index, 1);
731
-
732
- const newIndex = before ? this._order.indexOf(before) : this._order.length;
733
- if (before && newIndex === -1) {
734
- this.fire(new ErrorEvent(new Error(`Layer with id "${before}" does not exist on this map.`)));
735
- return;
736
- }
737
- this._order.splice(newIndex, 0, id);
738
-
739
- this._layerOrderChanged = true;
740
- }
741
-
742
- /**
743
- * Remove the layer with the given id from the style.
744
- *
745
- * If no such layer exists, an `error` event is fired.
746
- *
747
- * @param {string} id id of the layer to remove
748
- * @fires error
749
- */
750
- removeLayer(id: string) {
751
- this._checkLoaded();
752
-
753
- const layer = this._layers[id];
754
- if (!layer) {
755
- this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be removed.`)));
756
- return;
757
- }
758
-
759
- layer.setEventedParent(null);
760
-
761
- const index = this._order.indexOf(id);
762
- this._order.splice(index, 1);
763
-
764
- this._layerOrderChanged = true;
765
- this._changed = true;
766
- this._removedLayers[id] = layer;
767
- delete this._layers[id];
768
- delete this._serializedLayers[id];
769
- delete this._updatedLayers[id];
770
- delete this._updatedPaintProps[id];
771
-
772
- if (layer.onRemove) {
773
- layer.onRemove(this.map);
774
- }
775
- }
776
-
777
- /**
778
- * Return the style layer object with the given `id`.
779
- *
780
- * @param {string} id - id of the desired layer
781
- * @returns {?Object} a layer, if one with the given `id` exists
782
- */
783
- getLayer(id: string): Object {
784
- return this._layers[id];
785
- }
786
-
787
- /**
788
- * checks if a specific layer is present within the style.
789
- *
790
- * @param {string} id - id of the desired layer
791
- * @returns {boolean} a boolean specifying if the given layer is present
792
- */
793
- hasLayer(id: string): boolean {
794
- return id in this._layers;
795
- }
796
-
797
- setLayerZoomRange(layerId: string, minzoom: ?number, maxzoom: ?number) {
798
- this._checkLoaded();
799
-
800
- const layer = this.getLayer(layerId);
801
- if (!layer) {
802
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot have zoom extent.`)));
803
- return;
804
- }
805
-
806
- if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) return;
807
-
808
- if (minzoom != null) {
809
- layer.minzoom = minzoom;
810
- }
811
- if (maxzoom != null) {
812
- layer.maxzoom = maxzoom;
813
- }
814
- this._updateLayer(layer);
815
- }
816
-
817
- setFilter(layerId: string, filter: ?FilterSpecification, options: StyleSetterOptions = {}) {
818
- this._checkLoaded();
819
-
820
- const layer = this.getLayer(layerId);
821
- if (!layer) {
822
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be filtered.`)));
823
- return;
824
- }
825
-
826
- if (deepEqual(layer.filter, filter)) {
827
- return;
828
- }
829
-
830
- if (filter === null || filter === undefined) {
831
- layer.filter = undefined;
832
- this._updateLayer(layer);
833
- return;
834
- }
835
-
836
- if (this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) {
837
- return;
838
- }
839
-
840
- layer.filter = clone(filter);
841
- this._updateLayer(layer);
842
- }
843
-
844
- /**
845
- * Get a layer's filter object
846
- * @param {string} layer the layer to inspect
847
- * @returns {*} the layer's filter, if any
848
- */
849
- getFilter(layer: string) {
850
- return clone(this.getLayer(layer).filter);
851
- }
852
-
853
- setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {
854
- this._checkLoaded();
855
-
856
- const layer = this.getLayer(layerId);
857
- if (!layer) {
858
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be styled.`)));
859
- return;
860
- }
861
-
862
- if (deepEqual(layer.getLayoutProperty(name), value)) return;
863
-
864
- layer.setLayoutProperty(name, value, options);
865
- this._updateLayer(layer);
866
- }
867
-
868
- /**
869
- * Get a layout property's value from a given layer
870
- * @param {string} layerId the layer to inspect
871
- * @param {string} name the name of the layout property
872
- * @returns {*} the property value
873
- */
874
- getLayoutProperty(layerId: string, name: string) {
875
- const layer = this.getLayer(layerId);
876
- if (!layer) {
877
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style.`)));
878
- return;
879
- }
880
-
881
- return layer.getLayoutProperty(name);
882
- }
883
-
884
- setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {
885
- this._checkLoaded();
886
-
887
- const layer = this.getLayer(layerId);
888
- if (!layer) {
889
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be styled.`)));
890
- return;
891
- }
892
-
893
- if (deepEqual(layer.getPaintProperty(name), value)) return;
894
-
895
- const requiresRelayout = layer.setPaintProperty(name, value, options);
896
- if (requiresRelayout) {
897
- this._updateLayer(layer);
898
- }
899
-
900
- this._changed = true;
901
- this._updatedPaintProps[layerId] = true;
902
- }
903
-
904
- getPaintProperty(layer: string, name: string) {
905
- return this.getLayer(layer).getPaintProperty(name);
906
- }
907
-
908
- setFeatureState(target: { source: string; sourceLayer?: string; id: string | number; }, state: Object) {
909
- this._checkLoaded();
910
- const sourceId = target.source;
911
- const sourceLayer = target.sourceLayer;
912
- const sourceCache = this.sourceCaches[sourceId];
913
-
914
- if (sourceCache === undefined) {
915
- this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));
916
- return;
917
- }
918
- const sourceType = sourceCache.getSource().type;
919
- if (sourceType === 'geojson' && sourceLayer) {
920
- this.fire(new ErrorEvent(new Error(`GeoJSON sources cannot have a sourceLayer parameter.`)));
921
- return;
922
- }
923
- if (sourceType === 'vector' && !sourceLayer) {
924
- this.fire(new ErrorEvent(new Error(`The sourceLayer parameter must be provided for vector source types.`)));
925
- return;
926
- }
927
- if (target.id === undefined) {
928
- this.fire(new ErrorEvent(new Error(`The feature id parameter must be provided.`)));
929
- }
930
-
931
- sourceCache.setFeatureState(sourceLayer, target.id, state);
932
- }
933
-
934
- removeFeatureState(target: { source: string; sourceLayer?: string; id?: string | number; }, key?: string) {
935
- this._checkLoaded();
936
- const sourceId = target.source;
937
- const sourceCache = this.sourceCaches[sourceId];
938
-
939
- if (sourceCache === undefined) {
940
- this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));
941
- return;
942
- }
943
-
944
- const sourceType = sourceCache.getSource().type;
945
- const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined;
946
-
947
- if (sourceType === 'vector' && !sourceLayer) {
948
- this.fire(new ErrorEvent(new Error(`The sourceLayer parameter must be provided for vector source types.`)));
949
- return;
950
- }
951
-
952
- if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) {
953
- this.fire(new ErrorEvent(new Error(`A feature id is requred to remove its specific state property.`)));
954
- return;
955
- }
956
-
957
- sourceCache.removeFeatureState(sourceLayer, target.id, key);
958
- }
959
-
960
- getFeatureState(target: { source: string; sourceLayer?: string; id: string | number; }) {
961
- this._checkLoaded();
962
- const sourceId = target.source;
963
- const sourceLayer = target.sourceLayer;
964
- const sourceCache = this.sourceCaches[sourceId];
965
-
966
- if (sourceCache === undefined) {
967
- this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));
968
- return;
969
- }
970
- const sourceType = sourceCache.getSource().type;
971
- if (sourceType === 'vector' && !sourceLayer) {
972
- this.fire(new ErrorEvent(new Error(`The sourceLayer parameter must be provided for vector source types.`)));
973
- return;
974
- }
975
- if (target.id === undefined) {
976
- this.fire(new ErrorEvent(new Error(`The feature id parameter must be provided.`)));
977
- }
978
-
979
- return sourceCache.getFeatureState(sourceLayer, target.id);
980
- }
981
-
982
- getTransition() {
983
- return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition);
984
- }
985
-
986
- serialize() {
987
- return filterObject({
988
- version: this.stylesheet.version,
989
- name: this.stylesheet.name,
990
- metadata: this.stylesheet.metadata,
991
- light: this.stylesheet.light,
992
- center: this.stylesheet.center,
993
- zoom: this.stylesheet.zoom,
994
- bearing: this.stylesheet.bearing,
995
- pitch: this.stylesheet.pitch,
996
- sprite: this.stylesheet.sprite,
997
- glyphs: this.stylesheet.glyphs,
998
- transition: this.stylesheet.transition,
999
- sources: mapObject(this.sourceCaches, (source) => source.serialize()),
1000
- layers: this._serializeLayers(this._order)
1001
- }, (value) => { return value !== undefined; });
1002
- }
1003
-
1004
- _updateLayer(layer: StyleLayer) {
1005
- this._updatedLayers[layer.id] = true;
1006
- if (layer.source && !this._updatedSources[layer.source] &&
1007
- //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865)
1008
- this.sourceCaches[layer.source].getSource().type !== 'raster') {
1009
- this._updatedSources[layer.source] = 'reload';
1010
- this.sourceCaches[layer.source].pause();
1011
- }
1012
- this._changed = true;
1013
- }
1014
-
1015
- _flattenAndSortRenderedFeatures(sourceResults: Array<any>) {
1016
- // Feature order is complicated.
1017
- // The order between features in two 2D layers is always determined by layer order.
1018
- // The order between features in two 3D layers is always determined by depth.
1019
- // The order between a feature in a 2D layer and a 3D layer is tricky:
1020
- // Most often layer order determines the feature order in this case. If
1021
- // a line layer is above a extrusion layer the line feature will be rendered
1022
- // above the extrusion. If the line layer is below the extrusion layer,
1023
- // it will be rendered below it.
1024
- //
1025
- // There is a weird case though.
1026
- // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b
1027
- // Each layer has a feature that overlaps the other features.
1028
- // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above.
1029
- // The feature in line_layer is rendered above extrusion_layer_a.
1030
- // This means that that the line_layer feature is above the extrusion_layer_b feature despite
1031
- // it being in an earlier layer.
1032
-
1033
- const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion';
1034
-
1035
- const layerIndex = {};
1036
- const features3D = [];
1037
- for (let l = this._order.length - 1; l >= 0; l--) {
1038
- const layerId = this._order[l];
1039
- if (isLayer3D(layerId)) {
1040
- layerIndex[layerId] = l;
1041
- for (const sourceResult of sourceResults) {
1042
- const layerFeatures = sourceResult[layerId];
1043
- if (layerFeatures) {
1044
- for (const featureWrapper of layerFeatures) {
1045
- features3D.push(featureWrapper);
1046
- }
1047
- }
1048
- }
1049
- }
1050
- }
1051
-
1052
- features3D.sort((a, b) => {
1053
- return b.intersectionZ - a.intersectionZ;
1054
- });
1055
-
1056
- const features = [];
1057
- for (let l = this._order.length - 1; l >= 0; l--) {
1058
- const layerId = this._order[l];
1059
-
1060
- if (isLayer3D(layerId)) {
1061
- // add all 3D features that are in or above the current layer
1062
- for (let i = features3D.length - 1; i >= 0; i--) {
1063
- const topmost3D = features3D[i].feature;
1064
- if (layerIndex[topmost3D.layer.id] < l) break;
1065
- features.push(topmost3D);
1066
- features3D.pop();
1067
- }
1068
- } else {
1069
- for (const sourceResult of sourceResults) {
1070
- const layerFeatures = sourceResult[layerId];
1071
- if (layerFeatures) {
1072
- for (const featureWrapper of layerFeatures) {
1073
- features.push(featureWrapper.feature);
1074
- }
1075
- }
1076
- }
1077
- }
1078
- }
1079
-
1080
- return features;
1081
- }
1082
-
1083
- queryRenderedFeatures(queryGeometry: any, params: any, transform: Transform) {
1084
- if (params && params.filter) {
1085
- this._validate(validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params);
1086
- }
1087
-
1088
- const includedSources = {};
1089
- if (params && params.layers) {
1090
- if (!Array.isArray(params.layers)) {
1091
- this.fire(new ErrorEvent(new Error('parameters.layers must be an Array.')));
1092
- return [];
1093
- }
1094
- for (const layerId of params.layers) {
1095
- const layer = this._layers[layerId];
1096
- if (!layer) {
1097
- // this layer is not in the style.layers array
1098
- this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`)));
1099
- return [];
1100
- }
1101
- includedSources[layer.source] = true;
1102
- }
1103
- }
1104
-
1105
- const sourceResults = [];
1106
-
1107
- params.availableImages = this._availableImages;
1108
-
1109
- for (const id in this.sourceCaches) {
1110
- if (params.layers && !includedSources[id]) continue;
1111
- sourceResults.push(
1112
- queryRenderedFeatures(
1113
- this.sourceCaches[id],
1114
- this._layers,
1115
- this._serializedLayers,
1116
- queryGeometry,
1117
- params,
1118
- transform)
1119
- );
1120
- }
1121
-
1122
- if (this.placement) {
1123
- // If a placement has run, query against its CollisionIndex
1124
- // for symbol results, and treat it as an extra source to merge
1125
- sourceResults.push(
1126
- queryRenderedSymbols(
1127
- this._layers,
1128
- this._serializedLayers,
1129
- this.sourceCaches,
1130
- queryGeometry,
1131
- params,
1132
- this.placement.collisionIndex,
1133
- this.placement.retainedQueryData)
1134
- );
1135
- }
1136
-
1137
- return this._flattenAndSortRenderedFeatures(sourceResults);
1138
- }
1139
-
1140
- querySourceFeatures(sourceID: string, params: ?{sourceLayer: ?string, filter: ?Array<any>, validate?: boolean}) {
1141
- if (params && params.filter) {
1142
- this._validate(validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params);
1143
- }
1144
- const sourceCache = this.sourceCaches[sourceID];
1145
- return sourceCache ? querySourceFeatures(sourceCache, params) : [];
1146
- }
1147
-
1148
- addSourceType(name: string, SourceType: SourceClass, callback: Callback<void>) {
1149
- if (Style.getSourceType(name)) {
1150
- return callback(new Error(`A source type called "${name}" already exists.`));
1151
- }
1152
-
1153
- Style.setSourceType(name, SourceType);
1154
-
1155
- if (!SourceType.workerSourceURL) {
1156
- return callback(null, null);
1157
- }
1158
-
1159
- this.dispatcher.broadcast('loadWorkerSource', {
1160
- name,
1161
- url: SourceType.workerSourceURL
1162
- }, callback);
1163
- }
1164
-
1165
- getLight() {
1166
- return this.light.getLight();
1167
- }
1168
-
1169
- setLight(lightOptions: LightSpecification, options: StyleSetterOptions = {}) {
1170
- this._checkLoaded();
1171
-
1172
- const light = this.light.getLight();
1173
- let _update = false;
1174
- for (const key in lightOptions) {
1175
- if (!deepEqual(lightOptions[key], light[key])) {
1176
- _update = true;
1177
- break;
1178
- }
1179
- }
1180
- if (!_update) return;
1181
-
1182
- const parameters = {
1183
- now: browser.now(),
1184
- transition: extend({
1185
- duration: 300,
1186
- delay: 0
1187
- }, this.stylesheet.transition)
1188
- };
1189
-
1190
- this.light.setLight(lightOptions, options);
1191
- this.light.updateTransitions(parameters);
1192
- }
1193
-
1194
- _validate(validate: Validator, key: string, value: any, props: any, options: { validate?: boolean } = {}) {
1195
- if (options && options.validate === false) {
1196
- return false;
1197
- }
1198
- return emitValidationErrors(this, validate.call(validateStyle, extend({
1199
- key,
1200
- style: this.serialize(),
1201
- value,
1202
- styleSpec
1203
- }, props)));
1204
- }
1205
-
1206
- _remove() {
1207
- if (this._request) {
1208
- this._request.cancel();
1209
- this._request = null;
1210
- }
1211
- if (this._spriteRequest) {
1212
- this._spriteRequest.cancel();
1213
- this._spriteRequest = null;
1214
- }
1215
- rtlTextPluginEvented.off('pluginStateChange', this._rtlTextPluginCallback);
1216
- for (const layerId in this._layers) {
1217
- const layer: StyleLayer = this._layers[layerId];
1218
- layer.setEventedParent(null);
1219
- }
1220
- for (const id in this.sourceCaches) {
1221
- this.sourceCaches[id].clearTiles();
1222
- this.sourceCaches[id].setEventedParent(null);
1223
- }
1224
- this.imageManager.setEventedParent(null);
1225
- this.setEventedParent(null);
1226
- this.dispatcher.remove();
1227
- }
1228
-
1229
- _clearSource(id: string) {
1230
- this.sourceCaches[id].clearTiles();
1231
- }
1232
-
1233
- _reloadSource(id: string) {
1234
- this.sourceCaches[id].resume();
1235
- this.sourceCaches[id].reload();
1236
- }
1237
-
1238
- _updateSources(transform: Transform) {
1239
- for (const id in this.sourceCaches) {
1240
- this.sourceCaches[id].update(transform);
1241
- }
1242
- }
1243
-
1244
- _generateCollisionBoxes() {
1245
- for (const id in this.sourceCaches) {
1246
- this._reloadSource(id);
1247
- }
1248
- }
1249
-
1250
- _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement: boolean = false) {
1251
- let symbolBucketsChanged = false;
1252
- let placementCommitted = false;
1253
-
1254
- const layerTiles = {};
1255
-
1256
- for (const layerID of this._order) {
1257
- const styleLayer = this._layers[layerID];
1258
- if (styleLayer.type !== 'symbol') continue;
1259
-
1260
- if (!layerTiles[styleLayer.source]) {
1261
- const sourceCache = this.sourceCaches[styleLayer.source];
1262
- layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true)
1263
- .map((id) => sourceCache.getTileByID(id))
1264
- .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1));
1265
- }
1266
-
1267
- const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng);
1268
- symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged;
1269
- }
1270
- this.crossTileSymbolIndex.pruneUnusedLayers(this._order);
1271
-
1272
- // Anything that changes our "in progress" layer and tile indices requires us
1273
- // to start over. When we start over, we do a full placement instead of incremental
1274
- // to prevent starvation.
1275
- // We need to restart placement to keep layer indices in sync.
1276
- // Also force full placement when fadeDuration === 0 to ensure that newly loaded
1277
- // tiles will fully display symbols in their first frame
1278
- forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0;
1279
-
1280
- if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(browser.now(), transform.zoom))) {
1281
- this.pauseablePlacement = new PauseablePlacement(transform, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement);
1282
- this._layerOrderChanged = false;
1283
- }
1284
-
1285
- if (this.pauseablePlacement.isDone()) {
1286
- // the last placement finished running, but the next one hasn’t
1287
- // started yet because of the `stillRecent` check immediately
1288
- // above, so mark it stale to ensure that we request another
1289
- // render frame
1290
- this.placement.setStale();
1291
- } else {
1292
- this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles);
1293
-
1294
- if (this.pauseablePlacement.isDone()) {
1295
- this.placement = this.pauseablePlacement.commit(browser.now());
1296
- placementCommitted = true;
1297
- }
1298
-
1299
- if (symbolBucketsChanged) {
1300
- // since the placement gets split over multiple frames it is possible
1301
- // these buckets were processed before they were changed and so the
1302
- // placement is already stale while it is in progress
1303
- this.pauseablePlacement.placement.setStale();
1304
- }
1305
- }
1306
-
1307
- if (placementCommitted || symbolBucketsChanged) {
1308
- for (const layerID of this._order) {
1309
- const styleLayer = this._layers[layerID];
1310
- if (styleLayer.type !== 'symbol') continue;
1311
- this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]);
1312
- }
1313
- }
1314
-
1315
- // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols
1316
- const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(browser.now());
1317
- return needsRerender;
1318
- }
1319
-
1320
- _releaseSymbolFadeTiles() {
1321
- for (const id in this.sourceCaches) {
1322
- this.sourceCaches[id].releaseSymbolFadeTiles();
1323
- }
1324
- }
1325
-
1326
- // Callbacks from web workers
1327
-
1328
- getImages(mapId: string, params: {icons: Array<string>, source: string, tileID: OverscaledTileID, type: string}, callback: Callback<{[_: string]: StyleImage}>) {
1329
-
1330
- this.imageManager.getImages(params.icons, callback);
1331
-
1332
- // Apply queued image changes before setting the tile's dependencies so that the tile
1333
- // is not reloaded unecessarily. Without this forced update the reload could happen in cases
1334
- // like this one:
1335
- // - icons contains "my-image"
1336
- // - imageManager.getImages(...) triggers `onstyleimagemissing`
1337
- // - the user adds "my-image" within the callback
1338
- // - addImage adds "my-image" to this._changedImages
1339
- // - the next frame triggers a reload of this tile even though it already has the latest version
1340
- this._updateTilesForChangedImages();
1341
-
1342
- const sourceCache = this.sourceCaches[params.source];
1343
- if (sourceCache) {
1344
- sourceCache.setDependencies(params.tileID.key, params.type, params.icons);
1345
- }
1346
- }
1347
-
1348
- getGlyphs(mapId: string, params: {stacks: {[_: string]: Array<number>}}, callback: Callback<{[_: string]: {[_: number]: ?StyleGlyph}}>) {
1349
- this.glyphManager.getGlyphs(params.stacks, callback);
1350
- }
1351
-
1352
- getResource(mapId: string, params: RequestParameters, callback: ResponseCallback<any>): Cancelable {
1353
- return makeRequest(params, callback);
1354
- }
1355
- }
1356
-
1357
- Style.getSourceType = getSourceType;
1358
- Style.setSourceType = setSourceType;
1359
- Style.registerForPluginStateChange = registerForPluginStateChange;
1360
-
1361
- export default Style;