maplibre-gl 2.1.1 → 2.1.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/build/{banner.js → banner.ts} +1 -1
- package/build/generate-query-test-fixtures.ts +123 -0
- package/build/generate-shaders.ts +35 -0
- package/build/generate-struct-arrays.ts +7 -7
- package/build/generate-style-code.ts +8 -8
- package/build/generate-style-spec.ts +5 -4
- package/build/generate-typings.ts +16 -0
- package/build/readme.md +8 -18
- package/build/release-notes.js +9 -13
- package/build/{rollup_plugin_minify_style_spec.js → rollup_plugin_minify_style_spec.ts} +4 -3
- package/build/{rollup_plugins.js → rollup_plugins.ts} +11 -26
- package/dist/maplibre-gl-dev.js +522 -226
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1536 -1010
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +40 -61
- package/src/data/{array_types.ts → array_types.g.ts} +0 -0
- package/src/data/bucket/circle_bucket.ts +1 -1
- package/src/data/bucket/fill_bucket.test.ts +1 -1
- package/src/data/bucket/fill_bucket.ts +4 -4
- package/src/data/bucket/fill_extrusion_bucket.ts +1 -1
- package/src/data/bucket/line_bucket.test.ts +1 -1
- package/src/data/bucket/line_bucket.ts +6 -6
- package/src/data/bucket/symbol_bucket.test.ts +16 -16
- package/src/data/bucket/symbol_bucket.ts +53 -53
- package/src/data/bucket.ts +43 -43
- package/src/data/dem_data.ts +12 -12
- package/src/data/evaluation_feature.ts +10 -10
- package/src/data/feature_index.ts +37 -37
- package/src/data/feature_position_map.ts +5 -5
- package/src/data/index_array_type.ts +1 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/program_configuration.ts +46 -46
- package/src/data/segment.ts +14 -14
- package/src/geo/edge_insets.ts +2 -2
- package/src/geo/lng_lat.ts +4 -4
- package/src/geo/lng_lat_bounds.ts +35 -35
- package/src/geo/mercator_coordinate.ts +5 -5
- package/src/geo/transform.test.ts +1 -1
- package/src/geo/transform.ts +14 -14
- package/src/gl/context.ts +3 -3
- package/src/gl/types.ts +19 -19
- package/src/gl/value.ts +6 -6
- package/src/gl/vertex_buffer.test.ts +1 -1
- package/src/index.ts +24 -9
- package/src/render/draw_circle.ts +8 -8
- package/src/render/draw_collision_debug.ts +5 -5
- package/src/render/draw_line.ts +4 -4
- package/src/render/draw_symbol.ts +21 -21
- package/src/render/glyph_atlas.ts +12 -12
- package/src/render/glyph_manager.test.ts +10 -21
- package/src/render/glyph_manager.ts +33 -32
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +11 -11
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +10 -10
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +9 -9
- package/src/render/program/debug_program.ts +4 -4
- package/src/render/program/fill_extrusion_program.ts +31 -31
- package/src/render/program/fill_program.ts +29 -29
- package/src/render/program/heatmap_program.ts +12 -12
- package/src/render/program/hillshade_program.ts +12 -12
- package/src/render/program/line_program.ts +38 -38
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +96 -96
- package/src/render/program.ts +25 -25
- package/src/render/texture.ts +9 -9
- package/src/render/uniform_binding.ts +1 -1
- package/src/render/vertex_array_object.ts +13 -13
- package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
- package/src/shaders/background.fragment.glsl.g.ts +2 -0
- package/src/shaders/background.vertex.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/debug.fragment.glsl.g.ts +2 -0
- package/src/shaders/debug.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
- package/src/shaders/line.fragment.glsl.g.ts +2 -0
- package/src/shaders/line.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/raster.fragment.glsl.g.ts +2 -0
- package/src/shaders/raster.vertex.glsl.g.ts +2 -0
- package/src/shaders/shaders.ts +52 -55
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
- package/src/source/canvas_source.test.ts +11 -12
- package/src/source/canvas_source.ts +4 -4
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +2 -2
- package/src/source/image_source.ts +6 -6
- package/src/source/pixels_to_tile_units.ts +6 -6
- package/src/source/query_features.ts +20 -20
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_tile_source.test.ts +2 -2
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +32 -0
- package/src/source/source_cache.ts +7 -5
- package/src/source/source_state.ts +1 -1
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +15 -15
- package/src/source/tile_cache.ts +6 -6
- package/src/source/tile_id.test.ts +0 -1
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +5 -5
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker.ts +22 -22
- package/src/source/worker_source.ts +56 -56
- package/src/source/worker_tile.ts +4 -4
- package/src/style/evaluation_parameters.ts +3 -3
- package/src/style/format_section_override.test.ts +1 -1
- package/src/style/light.ts +10 -10
- package/src/style/load_glyph_range.test.ts +3 -3
- package/src/style/load_glyph_range.ts +6 -6
- package/src/style/load_sprite.ts +4 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +69 -69
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +2 -2
- package/src/style/style.ts +29 -29
- package/src/style/style_glyph.ts +8 -8
- package/src/style/style_image.ts +58 -58
- package/src/style/style_layer/background_style_layer.ts +2 -2
- package/src/style/style_layer/{background_style_layer_properties.ts → background_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/circle_style_layer.ts +10 -10
- package/src/style/style_layer/{circle_style_layer_properties.ts → circle_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/custom_style_layer.ts +17 -17
- package/src/style/style_layer/fill_extrusion_style_layer.ts +10 -10
- package/src/style/style_layer/{fill_extrusion_style_layer_properties.ts → fill_extrusion_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/fill_style_layer.ts +9 -9
- package/src/style/style_layer/{fill_style_layer_properties.ts → fill_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/heatmap_style_layer.ts +2 -2
- package/src/style/style_layer/{heatmap_style_layer_properties.ts → heatmap_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/hillshade_style_layer.ts +2 -2
- package/src/style/style_layer/{hillshade_style_layer_properties.ts → hillshade_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/line_style_layer.ts +9 -9
- package/src/style/style_layer/{line_style_layer_properties.ts → line_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -2
- package/src/style/style_layer/{raster_style_layer_properties.ts → raster_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/symbol_style_layer.ts +7 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer.ts +10 -10
- package/src/style/style_layer_index.ts +3 -3
- package/src/style/validate_style.ts +15 -15
- package/src/style-spec/error/validation_error.ts +1 -1
- package/src/style-spec/expression/compound_expression.ts +3 -3
- package/src/style-spec/expression/definitions/format.ts +11 -11
- package/src/style-spec/expression/definitions/interpolate.ts +5 -5
- package/src/style-spec/expression/definitions/match.ts +2 -2
- package/src/style-spec/expression/definitions/number_format.ts +11 -11
- package/src/style-spec/expression/expression.ts +8 -8
- package/src/style-spec/expression/index.ts +97 -97
- package/src/style-spec/expression/parsing_context.ts +11 -11
- package/src/style-spec/expression/types/collator.ts +9 -9
- package/src/style-spec/expression/types/resolved_image.ts +2 -2
- package/src/style-spec/expression/types.ts +14 -14
- package/src/style-spec/expression/values.ts +1 -1
- package/src/style-spec/feature_filter/index.ts +66 -66
- package/src/style-spec/function/convert.ts +3 -3
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/util/color_spaces.ts +8 -8
- package/src/style-spec/util/result.ts +4 -4
- package/src/style-spec/validate/validate_filter.ts +58 -58
- package/src/style-spec/validate/validate_source.ts +63 -63
- package/src/style-spec/visit.ts +11 -11
- package/src/symbol/collision_feature.test.ts +1 -1
- package/src/symbol/collision_feature.ts +10 -10
- package/src/symbol/collision_index.ts +26 -26
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.ts +7 -7
- package/src/symbol/placement.ts +72 -72
- package/src/symbol/projection.ts +30 -30
- package/src/symbol/quads.ts +30 -30
- package/src/symbol/shaping.ts +160 -160
- package/src/symbol/symbol_layout.ts +119 -119
- package/src/symbol/symbol_size.ts +29 -29
- package/src/symbol/symbol_style_layer.test.ts +1 -1
- package/src/types/cancelable.ts +1 -1
- package/src/types/tilejson.ts +13 -13
- package/src/ui/anchor.ts +1 -1
- package/src/ui/camera.test.ts +5 -5
- package/src/ui/camera.ts +18 -18
- package/src/ui/control/attribution_control.test.ts +51 -16
- package/src/ui/control/attribution_control.ts +35 -16
- package/src/ui/control/control.ts +40 -40
- package/src/ui/control/fullscreen_control.ts +1 -1
- package/src/ui/control/geolocate_control.test.ts +1 -1
- package/src/ui/control/geolocate_control.ts +102 -102
- package/src/ui/control/logo_control.test.ts +4 -4
- package/src/ui/control/navigation_control.ts +3 -3
- package/src/ui/control/scale_control.test.ts +2 -2
- package/src/ui/control/scale_control.ts +5 -5
- package/src/ui/events.ts +289 -200
- package/src/ui/handler/box_zoom.test.ts +1 -1
- package/src/ui/handler/box_zoom.ts +1 -1
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +1 -1
- package/src/ui/handler/drag_rotate.test.ts +1 -1
- package/src/ui/handler/keyboard.test.ts +1 -1
- package/src/ui/handler/keyboard.ts +51 -51
- package/src/ui/handler/map_event.test.ts +1 -1
- 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 +1 -1
- package/src/ui/handler/scroll_zoom.test.ts +1 -1
- package/src/ui/handler/scroll_zoom.ts +9 -9
- package/src/ui/handler/shim/drag_pan.ts +4 -4
- package/src/ui/handler/shim/drag_rotate.ts +1 -1
- package/src/ui/handler/shim/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler/tap_recognizer.ts +4 -4
- package/src/ui/handler/touch_pan.ts +2 -2
- package/src/ui/handler/touch_zoom_rotate.test.ts +1 -1
- package/src/ui/handler/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler_inertia.ts +6 -6
- package/src/ui/handler_manager.ts +44 -44
- package/src/ui/map/isMoving.test.ts +1 -1
- package/src/ui/map/isRotating.test.ts +1 -1
- package/src/ui/map/isZooming.test.ts +1 -1
- package/src/ui/map.test.ts +10 -4
- package/src/ui/map.ts +106 -101
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +12 -12
- package/src/ui/marker.ts +37 -37
- package/src/ui/popup.test.ts +7 -7
- package/src/ui/popup.ts +9 -9
- package/src/util/actor.test.ts +41 -10
- package/src/util/actor.ts +8 -8
- package/src/util/ajax.test.ts +29 -21
- package/src/util/ajax.ts +51 -30
- package/src/util/browser.ts +1 -1
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/color_ramp.ts +5 -5
- package/src/util/config.ts +2 -2
- package/src/util/dispatcher.ts +1 -1
- package/src/util/dom.ts +2 -2
- package/src/util/evented.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +3 -3
- package/src/util/image.ts +5 -5
- package/src/util/performance.ts +7 -7
- package/src/util/request_manager.ts +4 -4
- package/src/util/resolve_tokens.ts +4 -4
- package/src/util/struct_array.test.ts +1 -1
- package/src/util/struct_array.ts +15 -15
- package/src/util/task_queue.ts +3 -3
- package/src/util/tile_request_cache.ts +3 -3
- package/src/util/transferable_grid_index.ts +4 -4
- package/src/util/util.ts +8 -8
- package/src/util/web_worker.ts +4 -68
- package/src/util/web_worker_transfer.test.ts +3 -0
- package/src/util/web_worker_transfer.ts +21 -17
- package/src/util/worker_pool.ts +1 -1
- package/build/.eslintrc +0 -21
- package/build/glsl_to_js.js +0 -12
- package/build/post-ts-build.js +0 -43
- package/build/release-notes.md.ejs +0 -8
- package/build/test/build-tape.js +0 -17
- package/build/web_worker_replacement.js +0 -5
- package/dist/package.json +0 -1
- package/src/style-spec/validate_spec.test.ts +0 -29
- package/src/symbol/shaping.test.ts +0 -392
- package/src/types/glsl.d.ts +0 -4
|
@@ -19,7 +19,7 @@ import {SIZE_PACK_FACTOR} from './symbol_size';
|
|
|
19
19
|
import ONE_EM from './one_em';
|
|
20
20
|
import type {CanonicalTileID} from '../source/tile_id';
|
|
21
21
|
import type {Shaping, PositionedIcon, TextJustify} from './shaping';
|
|
22
|
-
import type {CollisionBoxArray} from '../data/array_types';
|
|
22
|
+
import type {CollisionBoxArray} from '../data/array_types.g';
|
|
23
23
|
import type {SymbolFeature} from '../data/bucket/symbol_bucket';
|
|
24
24
|
import type {StyleImage} from '../style/style_image';
|
|
25
25
|
import type {StyleGlyph} from '../style/style_glyph';
|
|
@@ -46,11 +46,11 @@ import murmur3 from 'murmurhash-js';
|
|
|
46
46
|
// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.
|
|
47
47
|
//
|
|
48
48
|
type Sizes = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
layoutTextSize: PossiblyEvaluatedPropertyValue<number>; // (3),
|
|
50
|
+
layoutIconSize: PossiblyEvaluatedPropertyValue<number>; // (3),
|
|
51
|
+
textMaxSize: PossiblyEvaluatedPropertyValue<number>; // (4),
|
|
52
|
+
compositeTextSizes: [PossiblyEvaluatedPropertyValue<number>, PossiblyEvaluatedPropertyValue<number>]; // (5),
|
|
53
|
+
compositeIconSizes: [PossiblyEvaluatedPropertyValue<number>, PossiblyEvaluatedPropertyValue<number>]; // (5)
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
type ShapedTextOrientations = {
|
|
@@ -76,37 +76,37 @@ export function evaluateVariableOffset(anchor: TextAnchor, offset: [number, numb
|
|
|
76
76
|
// solve for r where r^2 + r^2 = radialOffset^2
|
|
77
77
|
const hypotenuse = radialOffset / Math.sqrt(2);
|
|
78
78
|
switch (anchor) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
case 'top-right':
|
|
80
|
+
case 'top-left':
|
|
81
|
+
y = hypotenuse - baselineOffset;
|
|
82
|
+
break;
|
|
83
|
+
case 'bottom-right':
|
|
84
|
+
case 'bottom-left':
|
|
85
|
+
y = -hypotenuse + baselineOffset;
|
|
86
|
+
break;
|
|
87
|
+
case 'bottom':
|
|
88
|
+
y = -radialOffset + baselineOffset;
|
|
89
|
+
break;
|
|
90
|
+
case 'top':
|
|
91
|
+
y = radialOffset - baselineOffset;
|
|
92
|
+
break;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
switch (anchor) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
case 'top-right':
|
|
97
|
+
case 'bottom-right':
|
|
98
|
+
x = -hypotenuse;
|
|
99
|
+
break;
|
|
100
|
+
case 'top-left':
|
|
101
|
+
case 'bottom-left':
|
|
102
|
+
x = hypotenuse;
|
|
103
|
+
break;
|
|
104
|
+
case 'left':
|
|
105
|
+
x = radialOffset;
|
|
106
|
+
break;
|
|
107
|
+
case 'right':
|
|
108
|
+
x = -radialOffset;
|
|
109
|
+
break;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
return [x, y];
|
|
@@ -119,29 +119,29 @@ export function evaluateVariableOffset(anchor: TextAnchor, offset: [number, numb
|
|
|
119
119
|
offsetY = Math.abs(offsetY);
|
|
120
120
|
|
|
121
121
|
switch (anchor) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
case 'top-right':
|
|
123
|
+
case 'top-left':
|
|
124
|
+
case 'top':
|
|
125
|
+
y = offsetY - baselineOffset;
|
|
126
|
+
break;
|
|
127
|
+
case 'bottom-right':
|
|
128
|
+
case 'bottom-left':
|
|
129
|
+
case 'bottom':
|
|
130
|
+
y = -offsetY + baselineOffset;
|
|
131
|
+
break;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
switch (anchor) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
case 'top-right':
|
|
136
|
+
case 'bottom-right':
|
|
137
|
+
case 'right':
|
|
138
|
+
x = -offsetX;
|
|
139
|
+
break;
|
|
140
|
+
case 'top-left':
|
|
141
|
+
case 'bottom-left':
|
|
142
|
+
case 'left':
|
|
143
|
+
x = offsetX;
|
|
144
|
+
break;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return [x, y];
|
|
@@ -255,7 +255,7 @@ export function performSymbolLayout(
|
|
|
255
255
|
// writing mode, thus, default left justification is used. If Latin
|
|
256
256
|
// scripts would need to be supported, this should take into account other justifications.
|
|
257
257
|
shapedTextOrientations.vertical = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor,
|
|
258
|
-
|
|
258
|
+
'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
@@ -277,7 +277,7 @@ export function performSymbolLayout(
|
|
|
277
277
|
// If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply
|
|
278
278
|
// the offsets for the anchor in the placement step.
|
|
279
279
|
const shaping = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, 'center',
|
|
280
|
-
|
|
280
|
+
justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
|
|
281
281
|
if (shaping) {
|
|
282
282
|
shapedTextOrientations.horizontal[justification] = shaping;
|
|
283
283
|
singleLine = shaping.positionedLines.length === 1;
|
|
@@ -293,7 +293,7 @@ export function performSymbolLayout(
|
|
|
293
293
|
|
|
294
294
|
// Horizontal point or line label.
|
|
295
295
|
const shaping = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed,
|
|
296
|
-
|
|
296
|
+
textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
|
|
297
297
|
if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping;
|
|
298
298
|
|
|
299
299
|
// Vertical point label (if allowVerticalPlacement is enabled).
|
|
@@ -302,7 +302,7 @@ export function performSymbolLayout(
|
|
|
302
302
|
// Verticalized line label.
|
|
303
303
|
if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {
|
|
304
304
|
shapedTextOrientations.vertical = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify,
|
|
305
|
-
|
|
305
|
+
spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
}
|
|
@@ -346,14 +346,14 @@ export function performSymbolLayout(
|
|
|
346
346
|
// Choose the justification that matches the direction of the TextAnchor
|
|
347
347
|
export function getAnchorJustification(anchor: TextAnchor): TextJustify {
|
|
348
348
|
switch (anchor) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
349
|
+
case 'right':
|
|
350
|
+
case 'top-right':
|
|
351
|
+
case 'bottom-right':
|
|
352
|
+
return 'right';
|
|
353
|
+
case 'left':
|
|
354
|
+
case 'top-left':
|
|
355
|
+
case 'bottom-left':
|
|
356
|
+
return 'left';
|
|
357
357
|
}
|
|
358
358
|
return 'center';
|
|
359
359
|
}
|
|
@@ -366,15 +366,15 @@ export function getAnchorJustification(anchor: TextAnchor): TextJustify {
|
|
|
366
366
|
* @private
|
|
367
367
|
*/
|
|
368
368
|
function addFeature(bucket: SymbolBucket,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
369
|
+
feature: SymbolFeature,
|
|
370
|
+
shapedTextOrientations: ShapedTextOrientations,
|
|
371
|
+
shapedIcon: PositionedIcon,
|
|
372
|
+
imageMap: {[_: string]: StyleImage},
|
|
373
|
+
sizes: Sizes,
|
|
374
|
+
layoutTextSize: number,
|
|
375
|
+
layoutIconSize: number,
|
|
376
|
+
textOffset: [number, number],
|
|
377
|
+
isSDFIcon: boolean, canonical: CanonicalTileID) {
|
|
378
378
|
// To reduce the number of labels that jump around when zooming we need
|
|
379
379
|
// to use a text-size value that is the same for all zoom levels.
|
|
380
380
|
// bucket calculates text-size at a high zoom level so that all tiles can
|
|
@@ -410,7 +410,7 @@ function addFeature(bucket: SymbolBucket,
|
|
|
410
410
|
}
|
|
411
411
|
if (defaultHorizontalShaping) {
|
|
412
412
|
shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit,
|
|
413
|
-
|
|
413
|
+
layout.get('icon-text-fit-padding'), iconOffset, fontScale);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
|
|
@@ -491,25 +491,25 @@ const MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;
|
|
|
491
491
|
export {MAX_PACKED_SIZE};
|
|
492
492
|
|
|
493
493
|
function addTextVertices(bucket: SymbolBucket,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
494
|
+
anchor: Point,
|
|
495
|
+
shapedText: Shaping,
|
|
496
|
+
imageMap: {[_: string]: StyleImage},
|
|
497
|
+
layer: SymbolStyleLayer,
|
|
498
|
+
textAlongLine: boolean,
|
|
499
|
+
feature: SymbolFeature,
|
|
500
|
+
textOffset: [number, number],
|
|
501
|
+
lineArray: {
|
|
502
|
+
lineStartIndex: number;
|
|
503
|
+
lineLength: number;
|
|
504
|
+
},
|
|
505
|
+
writingMode: WritingMode,
|
|
506
|
+
placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>,
|
|
507
|
+
placedTextSymbolIndices: {[_: string]: number},
|
|
508
|
+
placedIconIndex: number,
|
|
509
|
+
sizes: Sizes,
|
|
510
|
+
canonical: CanonicalTileID) {
|
|
511
511
|
const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset,
|
|
512
|
-
|
|
512
|
+
layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);
|
|
513
513
|
|
|
514
514
|
const sizeData = bucket.textSizeData;
|
|
515
515
|
let textSizeData = null;
|
|
@@ -555,7 +555,7 @@ function addTextVertices(bucket: SymbolBucket,
|
|
|
555
555
|
}
|
|
556
556
|
|
|
557
557
|
function getDefaultHorizontalShaping(
|
|
558
|
-
|
|
558
|
+
horizontalShaping: Record<TextJustify, Shaping>
|
|
559
559
|
): Shaping | null {
|
|
560
560
|
// We don't care which shaping we get because this is used for collision purposes
|
|
561
561
|
// and all the justifications have the same collision box
|
|
@@ -571,30 +571,30 @@ function getDefaultHorizontalShaping(
|
|
|
571
571
|
* @private
|
|
572
572
|
*/
|
|
573
573
|
function addSymbol(bucket: SymbolBucket,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
574
|
+
anchor: Anchor,
|
|
575
|
+
line: Array<Point>,
|
|
576
|
+
shapedTextOrientations: ShapedTextOrientations,
|
|
577
|
+
shapedIcon: PositionedIcon | void,
|
|
578
|
+
imageMap: {[_: string]: StyleImage},
|
|
579
|
+
verticallyShapedIcon: PositionedIcon | void,
|
|
580
|
+
layer: SymbolStyleLayer,
|
|
581
|
+
collisionBoxArray: CollisionBoxArray,
|
|
582
|
+
featureIndex: number,
|
|
583
|
+
sourceLayerIndex: number,
|
|
584
|
+
bucketIndex: number,
|
|
585
|
+
textBoxScale: number,
|
|
586
|
+
textPadding: number,
|
|
587
|
+
textAlongLine: boolean,
|
|
588
|
+
textOffset: [number, number],
|
|
589
|
+
iconBoxScale: number,
|
|
590
|
+
iconPadding: number,
|
|
591
|
+
iconAlongLine: boolean,
|
|
592
|
+
iconOffset: [number, number],
|
|
593
|
+
feature: SymbolFeature,
|
|
594
|
+
sizes: Sizes,
|
|
595
|
+
isSDFIcon: boolean,
|
|
596
|
+
canonical: CanonicalTileID,
|
|
597
|
+
layoutTextSize: number) {
|
|
598
598
|
const lineArray = bucket.addToLineVertexArray(anchor, line);
|
|
599
599
|
|
|
600
600
|
let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;
|
|
@@ -11,29 +11,29 @@ const SIZE_PACK_FACTOR = 128;
|
|
|
11
11
|
export {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR};
|
|
12
12
|
|
|
13
13
|
export type SizeData = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
kind: 'constant';
|
|
15
|
+
layoutSize: number;
|
|
16
16
|
} | {
|
|
17
|
-
|
|
17
|
+
kind: 'source';
|
|
18
18
|
} | {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
kind: 'camera';
|
|
20
|
+
minZoom: number;
|
|
21
|
+
maxZoom: number;
|
|
22
|
+
minSize: number;
|
|
23
|
+
maxSize: number;
|
|
24
|
+
interpolationType: InterpolationType;
|
|
25
25
|
} | {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
kind: 'composite';
|
|
27
|
+
minZoom: number;
|
|
28
|
+
maxZoom: number;
|
|
29
|
+
interpolationType: InterpolationType;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
// For {text,icon}-size, get the bucket-level data that will be needed by
|
|
33
33
|
// the painter to set symbol-size-related uniforms
|
|
34
34
|
function getSizeData(
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
tileZoom: number,
|
|
36
|
+
value: PropertyValue<number, PossiblyEvaluatedPropertyValue<number>>
|
|
37
37
|
): SizeData {
|
|
38
38
|
const {expression} = value;
|
|
39
39
|
|
|
@@ -75,20 +75,20 @@ function getSizeData(
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function evaluateSizeForFeature(sizeData: SizeData,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
{
|
|
79
|
+
uSize,
|
|
80
|
+
uSizeT
|
|
81
|
+
}: {
|
|
82
|
+
uSize: number;
|
|
83
|
+
uSizeT: number;
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
lowerSize,
|
|
87
|
+
upperSize
|
|
88
|
+
}: {
|
|
89
|
+
lowerSize: number;
|
|
90
|
+
upperSize: number;
|
|
91
|
+
}) {
|
|
92
92
|
if (sizeData.kind === 'source') {
|
|
93
93
|
return lowerSize / SIZE_PACK_FACTOR;
|
|
94
94
|
} else if (sizeData.kind === 'composite') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SymbolStyleLayer, {getOverlapMode} from '../style/style_layer/symbol_style_layer';
|
|
2
2
|
import FormatSectionOverride from '../style/format_section_override';
|
|
3
|
-
import properties, {SymbolPaintPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties';
|
|
3
|
+
import properties, {SymbolPaintPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g';
|
|
4
4
|
import ZoomHistory from '../style/zoom_history';
|
|
5
5
|
import EvaluationParameters from '../style/evaluation_parameters';
|
|
6
6
|
|
package/src/types/cancelable.ts
CHANGED
package/src/types/tilejson.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export type TileJSON = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
tilejson: '2.2.0' | '2.1.0' | '2.0.1' | '2.0.0' | '1.0.0';
|
|
3
|
+
name?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
attribution?: string;
|
|
7
|
+
template?: string;
|
|
8
|
+
tiles: Array<string>;
|
|
9
|
+
grids?: Array<string>;
|
|
10
|
+
data?: Array<string>;
|
|
11
|
+
minzoom?: number;
|
|
12
|
+
maxzoom?: number;
|
|
13
|
+
bounds?: [number, number, number, number];
|
|
14
|
+
center?: [number, number, number];
|
|
15
15
|
};
|
package/src/ui/anchor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type PositionAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
2
2
|
|
|
3
3
|
export const anchorTranslate: {
|
|
4
|
-
|
|
4
|
+
[_ in PositionAnchor]: string;
|
|
5
5
|
} = {
|
|
6
6
|
'center': 'translate(-50%,-50%)',
|
|
7
7
|
'top': 'translate(-50%,0)',
|
package/src/ui/camera.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Camera from '../ui/camera';
|
|
|
2
2
|
import Transform from '../geo/transform';
|
|
3
3
|
import TaskQueue, {TaskID} from '../util/task_queue';
|
|
4
4
|
import browser from '../util/browser';
|
|
5
|
-
import {fixedLngLat, fixedNum} from '../../test/
|
|
5
|
+
import {fixedLngLat, fixedNum} from '../../test/unit/lib/fixed';
|
|
6
6
|
import {setMatchMedia} from '../util/test/util';
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
@@ -747,8 +747,8 @@ describe('#easeTo', () => {
|
|
|
747
747
|
});
|
|
748
748
|
|
|
749
749
|
camera.easeTo(
|
|
750
|
-
|
|
751
|
-
|
|
750
|
+
{center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45},
|
|
751
|
+
eventData);
|
|
752
752
|
done();
|
|
753
753
|
});
|
|
754
754
|
|
|
@@ -1091,8 +1091,8 @@ describe('#flyTo', () => {
|
|
|
1091
1091
|
});
|
|
1092
1092
|
|
|
1093
1093
|
camera.flyTo(
|
|
1094
|
-
|
|
1095
|
-
|
|
1094
|
+
{center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45, animate: false},
|
|
1095
|
+
eventData);
|
|
1096
1096
|
done();
|
|
1097
1097
|
});
|
|
1098
1098
|
|
package/src/ui/camera.ts
CHANGED
|
@@ -58,8 +58,8 @@ export type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Pa
|
|
|
58
58
|
* @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js-docs/example/3d-buildings/)
|
|
59
59
|
*/
|
|
60
60
|
export type CameraOptions = CenterZoomBearing & {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
pitch?: number;
|
|
62
|
+
around?: LngLatLike;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export type CenterZoomBearing = {
|
|
@@ -115,11 +115,11 @@ export type FitBoundsOptions = FlyToOptions & {
|
|
|
115
115
|
* [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion).
|
|
116
116
|
*/
|
|
117
117
|
export type AnimationOptions = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
duration?: number;
|
|
119
|
+
easing?: (_: number) => number;
|
|
120
|
+
offset?: PointLike;
|
|
121
|
+
animate?: boolean;
|
|
122
|
+
essential?: boolean;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
abstract class Camera extends Evented {
|
|
@@ -133,8 +133,8 @@ abstract class Camera extends Evented {
|
|
|
133
133
|
_bearingSnap: number;
|
|
134
134
|
_easeStart: number;
|
|
135
135
|
_easeOptions: {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
duration?: number;
|
|
137
|
+
easing?: (_: number) => number;
|
|
138
138
|
};
|
|
139
139
|
_easeId: string | void;
|
|
140
140
|
|
|
@@ -146,7 +146,7 @@ abstract class Camera extends Evented {
|
|
|
146
146
|
abstract _cancelRenderFrame(_: TaskID): void;
|
|
147
147
|
|
|
148
148
|
constructor(transform: Transform, options: {
|
|
149
|
-
|
|
149
|
+
bearingSnap: number;
|
|
150
150
|
}) {
|
|
151
151
|
super();
|
|
152
152
|
this._moving = false;
|
|
@@ -621,7 +621,7 @@ abstract class Camera extends Evented {
|
|
|
621
621
|
* @fires movestart
|
|
622
622
|
* @fires moveend
|
|
623
623
|
* @returns {Map} `this`
|
|
624
|
-
|
|
624
|
+
* @example
|
|
625
625
|
* var bbox = [[-79, 43], [-73, 45]];
|
|
626
626
|
* map.fitBounds(bbox, {
|
|
627
627
|
* padding: {top: 10, bottom:25, left: 15, right: 5}
|
|
@@ -656,7 +656,7 @@ abstract class Camera extends Evented {
|
|
|
656
656
|
* @fires movestart
|
|
657
657
|
* @fires moveend
|
|
658
658
|
* @returns {Map} `this`
|
|
659
|
-
|
|
659
|
+
* @example
|
|
660
660
|
* var p0 = [220, 400];
|
|
661
661
|
* var p1 = [500, 900];
|
|
662
662
|
* map.fitScreenCoordinates(p0, p1, map.getBearing(), {
|
|
@@ -802,8 +802,8 @@ abstract class Camera extends Evented {
|
|
|
802
802
|
* @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js-docs/example/game-controls/)
|
|
803
803
|
*/
|
|
804
804
|
easeTo(options: EaseToOptions & {
|
|
805
|
-
|
|
806
|
-
|
|
805
|
+
easeId?: string;
|
|
806
|
+
noMoveStart?: boolean;
|
|
807
807
|
}, eventData?: any) {
|
|
808
808
|
this._stop(false, options.easeId);
|
|
809
809
|
|
|
@@ -1209,12 +1209,12 @@ abstract class Camera extends Evented {
|
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
1211
|
_ease(frame: (_: number) => void,
|
|
1212
|
-
|
|
1213
|
-
|
|
1212
|
+
finish: () => void,
|
|
1213
|
+
options: {
|
|
1214
1214
|
animate?: boolean;
|
|
1215
1215
|
duration?: number;
|
|
1216
1216
|
easing?: (_: number) => number;
|
|
1217
|
-
|
|
1217
|
+
}) {
|
|
1218
1218
|
if (options.animate === false || options.duration === 0) {
|
|
1219
1219
|
frame(1);
|
|
1220
1220
|
finish();
|
|
@@ -1256,7 +1256,7 @@ abstract class Camera extends Evented {
|
|
|
1256
1256
|
const delta = center.lng - tr.center.lng;
|
|
1257
1257
|
center.lng +=
|
|
1258
1258
|
delta > 180 ? -360 :
|
|
1259
|
-
|
|
1259
|
+
delta < -180 ? 360 : 0;
|
|
1260
1260
|
}
|
|
1261
1261
|
}
|
|
1262
1262
|
|