maplibre-gl 3.1.0 → 3.2.0-pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-struct-arrays.ts +9 -12
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3303 -3398
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3899 -3531
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +28 -25
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +36 -26
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +61 -44
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +34 -27
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +12 -11
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/value.ts +1 -1
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +8 -14
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +12 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +85 -65
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +18 -16
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +5 -4
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +7 -1
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/shaders.ts +1 -3
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +75 -59
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +23 -10
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +17 -38
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +34 -24
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +11 -23
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +21 -28
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +39 -33
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +23 -48
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +392 -361
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +21 -26
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +181 -194
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +46 -42
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +14 -18
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +570 -1281
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +97 -8
- package/src/ui/map.ts +856 -702
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +220 -141
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +179 -147
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +2 -6
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +6 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +6 -0
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +2 -4
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {getVideo} from '../util/ajax';
|
|
2
2
|
import {ResourceType} from '../util/request_manager';
|
|
3
3
|
|
|
4
|
-
import ImageSource from './image_source';
|
|
4
|
+
import {ImageSource} from './image_source';
|
|
5
5
|
import rasterBoundsAttributes from '../data/raster_bounds_attributes';
|
|
6
|
-
import SegmentVector from '../data/segment';
|
|
7
|
-
import Texture from '../render/texture';
|
|
6
|
+
import {SegmentVector} from '../data/segment';
|
|
7
|
+
import {Texture} from '../render/texture';
|
|
8
8
|
import {Event, ErrorEvent} from '../util/evented';
|
|
9
9
|
import {ValidationError} from '@maplibre/maplibre-gl-style-spec';
|
|
10
10
|
|
|
11
|
-
import type Map from '../ui/map';
|
|
12
|
-
import type Dispatcher from '../util/dispatcher';
|
|
11
|
+
import type {Map} from '../ui/map';
|
|
12
|
+
import type {Dispatcher} from '../util/dispatcher';
|
|
13
13
|
import type {Evented} from '../util/evented';
|
|
14
14
|
import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
15
15
|
|
|
@@ -17,7 +17,10 @@ import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
17
17
|
* A data source containing video.
|
|
18
18
|
* (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.)
|
|
19
19
|
*
|
|
20
|
+
* @group Sources
|
|
21
|
+
*
|
|
20
22
|
* @example
|
|
23
|
+
* ```ts
|
|
21
24
|
* // add to map
|
|
22
25
|
* map.addSource('some id', {
|
|
23
26
|
* type: 'video',
|
|
@@ -34,7 +37,7 @@ import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
34
37
|
* });
|
|
35
38
|
*
|
|
36
39
|
* // update
|
|
37
|
-
*
|
|
40
|
+
* let mySource = map.getSource('some id');
|
|
38
41
|
* mySource.setCoordinates([
|
|
39
42
|
* [-76.54335737228394, 39.18579907229748],
|
|
40
43
|
* [-76.52803659439087, 39.1838364847587],
|
|
@@ -43,17 +46,15 @@ import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
43
46
|
* ]);
|
|
44
47
|
*
|
|
45
48
|
* map.removeSource('some id'); // remove
|
|
46
|
-
*
|
|
49
|
+
* ```
|
|
50
|
+
* @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)
|
|
47
51
|
*/
|
|
48
|
-
class VideoSource extends ImageSource {
|
|
52
|
+
export class VideoSource extends ImageSource {
|
|
49
53
|
options: VideoSourceSpecification;
|
|
50
54
|
urls: Array<string>;
|
|
51
55
|
video: HTMLVideoElement;
|
|
52
56
|
roundZoom: boolean;
|
|
53
57
|
|
|
54
|
-
/**
|
|
55
|
-
* @private
|
|
56
|
-
*/
|
|
57
58
|
constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
|
|
58
59
|
super(id, options, dispatcher, eventedParent);
|
|
59
60
|
this.roundZoom = true;
|
|
@@ -61,7 +62,7 @@ class VideoSource extends ImageSource {
|
|
|
61
62
|
this.options = options;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
load() {
|
|
65
|
+
load = () => {
|
|
65
66
|
this._loaded = false;
|
|
66
67
|
const options = this.options;
|
|
67
68
|
|
|
@@ -91,7 +92,7 @@ class VideoSource extends ImageSource {
|
|
|
91
92
|
this._finishLoading();
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
|
-
}
|
|
95
|
+
};
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* Pauses the video.
|
|
@@ -113,7 +114,6 @@ class VideoSource extends ImageSource {
|
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
116
|
* Sets playback to a timestamp, in seconds.
|
|
116
|
-
* @private
|
|
117
117
|
*/
|
|
118
118
|
seek(seconds: number) {
|
|
119
119
|
if (this.video) {
|
|
@@ -127,9 +127,9 @@ class VideoSource extends ImageSource {
|
|
|
127
127
|
/**
|
|
128
128
|
* Returns the HTML `video` element.
|
|
129
129
|
*
|
|
130
|
-
* @returns
|
|
130
|
+
* @returns The HTML `video` element.
|
|
131
131
|
*/
|
|
132
|
-
getVideo() {
|
|
132
|
+
getVideo(): HTMLVideoElement {
|
|
133
133
|
return this.video;
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -146,14 +146,9 @@ class VideoSource extends ImageSource {
|
|
|
146
146
|
/**
|
|
147
147
|
* Sets the video's coordinates and re-renders the map.
|
|
148
148
|
*
|
|
149
|
-
* @
|
|
150
|
-
* @instance
|
|
151
|
-
* @memberof VideoSource
|
|
152
|
-
* @returns {VideoSource} this
|
|
149
|
+
* @returns `this`
|
|
153
150
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
prepare() {
|
|
151
|
+
prepare = (): this => {
|
|
157
152
|
if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) {
|
|
158
153
|
return; // not enough data for current position
|
|
159
154
|
}
|
|
@@ -190,19 +185,17 @@ class VideoSource extends ImageSource {
|
|
|
190
185
|
if (newTilesLoaded) {
|
|
191
186
|
this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));
|
|
192
187
|
}
|
|
193
|
-
}
|
|
188
|
+
};
|
|
194
189
|
|
|
195
|
-
serialize() {
|
|
190
|
+
serialize = (): VideoSourceSpecification => {
|
|
196
191
|
return {
|
|
197
192
|
type: 'video',
|
|
198
193
|
urls: this.urls,
|
|
199
194
|
coordinates: this.coordinates
|
|
200
195
|
};
|
|
201
|
-
}
|
|
196
|
+
};
|
|
202
197
|
|
|
203
198
|
hasTransition() {
|
|
204
199
|
return this.video && !this.video.paused;
|
|
205
200
|
}
|
|
206
201
|
}
|
|
207
|
-
|
|
208
|
-
export default VideoSource;
|
package/src/source/worker.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import Actor from '../util/actor';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import GeoJSONWorkerSource from './geojson_worker_source';
|
|
1
|
+
import {Actor} from '../util/actor';
|
|
2
|
+
import {StyleLayerIndex} from '../style/style_layer_index';
|
|
3
|
+
import {VectorTileWorkerSource} from './vector_tile_worker_source';
|
|
4
|
+
import {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source';
|
|
5
|
+
import {GeoJSONWorkerSource} from './geojson_worker_source';
|
|
7
6
|
import {plugin as globalRTLTextPlugin} from './rtl_text_plugin';
|
|
8
7
|
import {isWorker} from '../util/util';
|
|
9
8
|
|
|
@@ -22,7 +21,7 @@ import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
22
21
|
import type {PluginState} from './rtl_text_plugin';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
24
|
+
* The Worker class responsidble for background thread related execution
|
|
26
25
|
*/
|
|
27
26
|
export default class Worker {
|
|
28
27
|
self: WorkerGlobalScopeInterface;
|
|
@@ -174,7 +173,6 @@ export default class Worker {
|
|
|
174
173
|
* Load a {@link WorkerSource} script at params.url. The script is run
|
|
175
174
|
* (using importScripts) with `registerWorkerSource` in scope, which is a
|
|
176
175
|
* function taking `(name, workerSourceObject)`.
|
|
177
|
-
* @private
|
|
178
176
|
*/
|
|
179
177
|
loadWorkerSource(map: string, params: {
|
|
180
178
|
url: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {RequestParameters} from '../util/ajax';
|
|
2
2
|
import type {RGBAImage, AlphaImage} from '../util/image';
|
|
3
3
|
import type {GlyphPositions} from '../render/glyph_atlas';
|
|
4
|
-
import type ImageAtlas from '../render/image_atlas';
|
|
4
|
+
import type {ImageAtlas} from '../render/image_atlas';
|
|
5
5
|
import type {OverscaledTileID} from './tile_id';
|
|
6
6
|
import type {Bucket} from '../data/bucket';
|
|
7
|
-
import type FeatureIndex from '../data/feature_index';
|
|
7
|
+
import type {FeatureIndex} from '../data/feature_index';
|
|
8
8
|
import type {CollisionBoxArray} from '../data/array_types.g';
|
|
9
|
-
import type DEMData from '../data/dem_data';
|
|
9
|
+
import type {DEMData} from '../data/dem_data';
|
|
10
10
|
import type {StyleGlyph} from '../style/style_glyph';
|
|
11
11
|
import type {StyleImage} from '../style/style_image';
|
|
12
12
|
import type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
@@ -40,6 +40,9 @@ export type WorkerDEMTileParameters = TileParameters & {
|
|
|
40
40
|
encoding: 'mapbox' | 'terrarium';
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The worker tile's result type
|
|
45
|
+
*/
|
|
43
46
|
export type WorkerTileResult = {
|
|
44
47
|
buckets: Array<Bucket>;
|
|
45
48
|
imageAtlas: ImageAtlas;
|
|
@@ -71,11 +74,6 @@ export type WorkerDEMTileCallback = (err?: Error | null, result?: DEMData | null
|
|
|
71
74
|
* `dispatcher.getActor().send('source-type.methodname', params, callback)`.
|
|
72
75
|
*
|
|
73
76
|
* @see {@link Map#addSourceType}
|
|
74
|
-
* @private
|
|
75
|
-
*
|
|
76
|
-
* @class WorkerSource
|
|
77
|
-
* @param actor
|
|
78
|
-
* @param layerIndex
|
|
79
77
|
*/
|
|
80
78
|
export interface WorkerSource {
|
|
81
79
|
availableImages: Array<string>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import WorkerTile from '../source/worker_tile';
|
|
2
|
-
import
|
|
1
|
+
import {WorkerTile} from '../source/worker_tile';
|
|
2
|
+
import {GeoJSONWrapper, Feature} from '../source/geojson_wrapper';
|
|
3
3
|
import {OverscaledTileID} from '../source/tile_id';
|
|
4
|
-
import StyleLayerIndex from '../style/style_layer_index';
|
|
4
|
+
import {StyleLayerIndex} from '../style/style_layer_index';
|
|
5
5
|
import {WorkerTileParameters} from './worker_source';
|
|
6
|
-
import Actor from '../util/actor';
|
|
6
|
+
import {Actor} from '../util/actor';
|
|
7
7
|
import {VectorTile} from '@mapbox/vector-tile';
|
|
8
8
|
|
|
9
9
|
function createWorkerTile() {
|
|
@@ -19,7 +19,7 @@ function createWorkerTile() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function createWrapper() {
|
|
22
|
-
return new
|
|
22
|
+
return new GeoJSONWrapper([{
|
|
23
23
|
type: 1,
|
|
24
24
|
geometry: [0, 0],
|
|
25
25
|
tags: {}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import FeatureIndex from '../data/feature_index';
|
|
2
|
-
|
|
1
|
+
import {FeatureIndex} from '../data/feature_index';
|
|
3
2
|
import {performSymbolLayout} from '../symbol/symbol_layout';
|
|
4
3
|
import {CollisionBoxArray} from '../data/array_types.g';
|
|
5
|
-
import DictionaryCoder from '../util/dictionary_coder';
|
|
6
|
-
import SymbolBucket from '../data/bucket/symbol_bucket';
|
|
7
|
-
import LineBucket from '../data/bucket/line_bucket';
|
|
8
|
-
import FillBucket from '../data/bucket/fill_bucket';
|
|
9
|
-
import FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket';
|
|
4
|
+
import {DictionaryCoder} from '../util/dictionary_coder';
|
|
5
|
+
import {SymbolBucket} from '../data/bucket/symbol_bucket';
|
|
6
|
+
import {LineBucket} from '../data/bucket/line_bucket';
|
|
7
|
+
import {FillBucket} from '../data/bucket/fill_bucket';
|
|
8
|
+
import {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';
|
|
10
9
|
import {warnOnce, mapObject} from '../util/util';
|
|
11
|
-
import ImageAtlas from '../render/image_atlas';
|
|
12
|
-
import GlyphAtlas from '../render/glyph_atlas';
|
|
13
|
-
import EvaluationParameters from '../style/evaluation_parameters';
|
|
10
|
+
import {ImageAtlas} from '../render/image_atlas';
|
|
11
|
+
import {GlyphAtlas} from '../render/glyph_atlas';
|
|
12
|
+
import {EvaluationParameters} from '../style/evaluation_parameters';
|
|
14
13
|
import {OverscaledTileID} from './tile_id';
|
|
15
14
|
|
|
16
15
|
import type {Bucket} from '../data/bucket';
|
|
17
|
-
import type Actor from '../util/actor';
|
|
18
|
-
import type StyleLayer from '../style/style_layer';
|
|
19
|
-
import type StyleLayerIndex from '../style/style_layer_index';
|
|
16
|
+
import type {Actor} from '../util/actor';
|
|
17
|
+
import type {StyleLayer} from '../style/style_layer';
|
|
18
|
+
import type {StyleLayerIndex} from '../style/style_layer_index';
|
|
20
19
|
import type {StyleImage} from '../style/style_image';
|
|
21
20
|
import type {StyleGlyph} from '../style/style_glyph';
|
|
22
21
|
import type {
|
|
@@ -26,7 +25,7 @@ import type {
|
|
|
26
25
|
import type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
27
26
|
import type {VectorTile} from '@mapbox/vector-tile';
|
|
28
27
|
|
|
29
|
-
class WorkerTile {
|
|
28
|
+
export class WorkerTile {
|
|
30
29
|
tileID: OverscaledTileID;
|
|
31
30
|
uid: string;
|
|
32
31
|
zoom: number;
|
|
@@ -232,5 +231,3 @@ function recalculateLayers(layers: ReadonlyArray<StyleLayer>, zoom: number, avai
|
|
|
232
231
|
layer.recalculate(parameters, availableImages);
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
|
-
|
|
236
|
-
export default WorkerTile;
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import CustomStyleLayer from './style_layer/custom_style_layer';
|
|
11
|
-
import type {CustomLayerInterface} from './style_layer/custom_style_layer';
|
|
1
|
+
import {CircleStyleLayer} from './style_layer/circle_style_layer';
|
|
2
|
+
import {HeatmapStyleLayer} from './style_layer/heatmap_style_layer';
|
|
3
|
+
import {HillshadeStyleLayer} from './style_layer/hillshade_style_layer';
|
|
4
|
+
import {FillStyleLayer} from './style_layer/fill_style_layer';
|
|
5
|
+
import {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer';
|
|
6
|
+
import {LineStyleLayer} from './style_layer/line_style_layer';
|
|
7
|
+
import {SymbolStyleLayer} from './style_layer/symbol_style_layer';
|
|
8
|
+
import {BackgroundStyleLayer} from './style_layer/background_style_layer';
|
|
9
|
+
import {RasterStyleLayer} from './style_layer/raster_style_layer';
|
|
10
|
+
import {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer';
|
|
12
11
|
|
|
13
12
|
import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
circle,
|
|
17
|
-
heatmap,
|
|
18
|
-
hillshade,
|
|
19
|
-
fill,
|
|
20
|
-
'fill-extrusion': fillExtrusion,
|
|
21
|
-
line,
|
|
22
|
-
symbol,
|
|
23
|
-
background,
|
|
24
|
-
raster
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {
|
|
14
|
+
export function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {
|
|
28
15
|
if (layer.type === 'custom') {
|
|
29
16
|
return new CustomStyleLayer(layer);
|
|
30
|
-
}
|
|
31
|
-
|
|
17
|
+
}
|
|
18
|
+
switch (layer.type) {
|
|
19
|
+
case 'background':
|
|
20
|
+
return new BackgroundStyleLayer(layer);
|
|
21
|
+
case 'circle':
|
|
22
|
+
return new CircleStyleLayer(layer);
|
|
23
|
+
case 'fill':
|
|
24
|
+
return new FillStyleLayer(layer);
|
|
25
|
+
case 'fill-extrusion':
|
|
26
|
+
return new FillExtrusionStyleLayer(layer);
|
|
27
|
+
case 'heatmap':
|
|
28
|
+
return new HeatmapStyleLayer(layer);
|
|
29
|
+
case 'hillshade':
|
|
30
|
+
return new HillshadeStyleLayer(layer);
|
|
31
|
+
case 'line':
|
|
32
|
+
return new LineStyleLayer(layer);
|
|
33
|
+
case 'raster':
|
|
34
|
+
return new RasterStyleLayer(layer);
|
|
35
|
+
case 'symbol':
|
|
36
|
+
return new SymbolStyleLayer(layer);
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ZoomHistory from './zoom_history';
|
|
1
|
+
import {ZoomHistory} from './zoom_history';
|
|
2
2
|
import {isStringInSupportedScript} from '../util/script_detection';
|
|
3
3
|
import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';
|
|
4
4
|
|
|
@@ -10,7 +10,10 @@ export type CrossfadeParameters = {
|
|
|
10
10
|
t: number;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A parameter that can be evaluated to a value
|
|
15
|
+
*/
|
|
16
|
+
export class EvaluationParameters {
|
|
14
17
|
zoom: number;
|
|
15
18
|
now: number;
|
|
16
19
|
fadeDuration: number;
|
|
@@ -56,5 +59,3 @@ class EvaluationParameters {
|
|
|
56
59
|
{fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction};
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
export default EvaluationParameters;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {EvaluationContext, FormattedSection, createExpression, StyleExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
import properties from './style_layer/symbol_style_layer_properties.g';
|
|
3
3
|
import {PossiblyEvaluatedPropertyValue} from './properties';
|
|
4
|
-
import FormatSectionOverride from './format_section_override';
|
|
5
|
-
import EvaluationParameters from './evaluation_parameters';
|
|
4
|
+
import {FormatSectionOverride} from './format_section_override';
|
|
5
|
+
import {EvaluationParameters} from './evaluation_parameters';
|
|
6
6
|
|
|
7
7
|
describe('evaluate', () => {
|
|
8
8
|
|
|
@@ -5,7 +5,7 @@ import {register} from '../util/web_worker_transfer';
|
|
|
5
5
|
|
|
6
6
|
// This is an internal expression class. It is only used in GL JS and
|
|
7
7
|
// has GL JS dependencies which can break the standalone style-spec module
|
|
8
|
-
export
|
|
8
|
+
export class FormatSectionOverride<T> implements Expression {
|
|
9
9
|
type: Type;
|
|
10
10
|
defaultValue: PossiblyEvaluatedPropertyValue<T>;
|
|
11
11
|
|
package/src/style/light.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Light from './light';
|
|
1
|
+
import {Light} from './light';
|
|
2
2
|
import {Color, latest as styleSpec, LightSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
3
3
|
import {sphericalToCartesian} from '../util/util';
|
|
4
|
-
import EvaluationParameters from './evaluation_parameters';
|
|
4
|
+
import {EvaluationParameters} from './evaluation_parameters';
|
|
5
5
|
import {TransitionParameters} from './properties';
|
|
6
6
|
|
|
7
7
|
const spec = styleSpec.light;
|
package/src/style/light.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from './validate_style';
|
|
10
10
|
|
|
11
11
|
import type {StylePropertySpecification, LightSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
12
|
-
import type EvaluationParameters from './evaluation_parameters';
|
|
12
|
+
import type {EvaluationParameters} from './evaluation_parameters';
|
|
13
13
|
import type {StyleSetterOptions} from '../style/style';
|
|
14
14
|
import {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties';
|
|
15
15
|
|
|
@@ -69,7 +69,7 @@ let lightProperties: Properties<Props>;
|
|
|
69
69
|
/*
|
|
70
70
|
* Represents the light used to light extruded features.
|
|
71
71
|
*/
|
|
72
|
-
class Light extends Evented {
|
|
72
|
+
export class Light extends Evented {
|
|
73
73
|
_transitionable: Transitionable<Props>;
|
|
74
74
|
_transitioning: Transitioning<Props>;
|
|
75
75
|
properties: PossiblyEvaluated<Props, PropsPossiblyEvaluated>;
|
|
@@ -87,7 +87,7 @@ class Light extends Evented {
|
|
|
87
87
|
this._transitioning = this._transitionable.untransitioned();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
getLight() {
|
|
90
|
+
getLight(): LightSpecification {
|
|
91
91
|
return this._transitionable.serialize();
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -133,5 +133,3 @@ class Light extends Evented {
|
|
|
133
133
|
})));
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
export default Light;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import {RequestManager} from '../util/request_manager';
|
|
4
|
-
import loadGlyphRange from './load_glyph_range';
|
|
4
|
+
import {loadGlyphRange} from './load_glyph_range';
|
|
5
5
|
import {fakeXhr} from 'nise';
|
|
6
6
|
|
|
7
7
|
test('loadGlyphRange', done => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {getArrayBuffer} from '../util/ajax';
|
|
2
2
|
import {ResourceType} from '../util/request_manager';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {parseGlyphPbf} from './parse_glyph_pbf';
|
|
5
5
|
|
|
6
6
|
import type {StyleGlyph} from './style_glyph';
|
|
7
7
|
import type {RequestManager} from '../util/request_manager';
|
|
8
8
|
import type {Callback} from '../types/callback';
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export function loadGlyphRange(fontstack: string,
|
|
11
11
|
range: number,
|
|
12
12
|
urlTemplate: string,
|
|
13
13
|
requestManager: RequestManager,
|
|
@@ -28,7 +28,7 @@ export default function loadGlyphRange(fontstack: string,
|
|
|
28
28
|
} else if (data) {
|
|
29
29
|
const glyphs = {};
|
|
30
30
|
|
|
31
|
-
for (const glyph of
|
|
31
|
+
for (const glyph of parseGlyphPbf(data)) {
|
|
32
32
|
glyphs[glyph.id] = glyph;
|
|
33
33
|
}
|
|
34
34
|
|
package/src/style/load_sprite.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {getJSON} from '../util/ajax';
|
|
2
|
-
import ImageRequest from '../util/image_request';
|
|
2
|
+
import {ImageRequest} from '../util/image_request';
|
|
3
3
|
import {ResourceType} from '../util/request_manager';
|
|
4
4
|
|
|
5
|
-
import browser from '../util/browser';
|
|
5
|
+
import {browser} from '../util/browser';
|
|
6
6
|
import {coerceSpriteToArray} from '../util/style';
|
|
7
7
|
|
|
8
8
|
import type {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
@@ -11,7 +11,7 @@ import type {RequestManager} from '../util/request_manager';
|
|
|
11
11
|
import type {Callback} from '../types/callback';
|
|
12
12
|
import type {Cancelable} from '../types/cancelable';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export function loadSprite(
|
|
15
15
|
originalSprite: SpriteSpecification,
|
|
16
16
|
requestManager: RequestManager,
|
|
17
17
|
pixelRatio: number,
|
|
@@ -35,7 +35,7 @@ function readGlyph(tag: number, glyph: any, pbf: Protobuf) {
|
|
|
35
35
|
else if (tag === 7) glyph.advance = pbf.readVarint();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export
|
|
38
|
+
export function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array<StyleGlyph> {
|
|
39
39
|
return new Protobuf(data).readFields(readFontstacks, []);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import browser from '../util/browser';
|
|
1
|
+
import {browser} from '../util/browser';
|
|
2
2
|
|
|
3
3
|
import {Placement} from '../symbol/placement';
|
|
4
4
|
|
|
5
|
-
import type Transform from '../geo/transform';
|
|
6
|
-
import type StyleLayer from './style_layer';
|
|
7
|
-
import type SymbolStyleLayer from './style_layer/symbol_style_layer';
|
|
8
|
-
import type Tile from '../source/tile';
|
|
5
|
+
import type {Transform} from '../geo/transform';
|
|
6
|
+
import type {StyleLayer} from './style_layer';
|
|
7
|
+
import type {SymbolStyleLayer} from './style_layer/symbol_style_layer';
|
|
8
|
+
import type {Tile} from '../source/tile';
|
|
9
9
|
import type {BucketPart} from '../symbol/placement';
|
|
10
|
-
import Terrain from '../render/terrain';
|
|
10
|
+
import {Terrain} from '../render/terrain';
|
|
11
11
|
|
|
12
12
|
class LayerPlacement {
|
|
13
13
|
_sortAcrossTiles: boolean;
|
|
@@ -60,7 +60,7 @@ class LayerPlacement {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
class PauseablePlacement {
|
|
63
|
+
export class PauseablePlacement {
|
|
64
64
|
placement: Placement;
|
|
65
65
|
_done: boolean;
|
|
66
66
|
_currentPlacementIndex: number;
|
|
@@ -135,5 +135,3 @@ class PauseablePlacement {
|
|
|
135
135
|
return this.placement;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
export default PauseablePlacement;
|