maplibre-gl 2.0.4 → 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} +12 -26
- package/dist/maplibre-gl-dev.js +54885 -0
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1583 -1023
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +99 -141
- package/src/css/maplibre-gl.css +36 -36
- 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 +56 -56
- 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 +47 -47
- 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_debug.ts +1 -1
- 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 +34 -33
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +16 -14
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +11 -11
- 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 +41 -41
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +97 -97
- 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_source.test.ts +2 -1
- package/src/source/geojson_source.ts +1 -1
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +153 -0
- 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 +4 -3
- package/src/source/raster_dem_tile_source.ts +1 -1
- package/src/source/raster_tile_source.test.ts +4 -3
- package/src/source/raster_tile_source.ts +1 -1
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +33 -1
- 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.test.ts +6 -4
- package/src/source/tile_cache.ts +6 -6
- package/src/source/tile_id.test.ts +10 -13
- package/src/source/tile_id.ts +2 -2
- package/src/source/vector_tile_source.test.ts +17 -5
- package/src/source/vector_tile_source.ts +4 -5
- 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 -5
- package/src/style/load_glyph_range.ts +6 -6
- package/src/style/load_sprite.ts +5 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +70 -70
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +26 -15
- package/src/style/style.ts +30 -30
- 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 +19 -19
- package/src/style/style_layer/fill_extrusion_style_layer.ts +11 -11
- 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 +26 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +6 -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/CHANGELOG.md +6 -0
- 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/package.json +1 -1
- package/src/style-spec/reference/v8.json +68 -2
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/types.ts +2 -0
- 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 +43 -43
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.test.ts +42 -19
- package/src/symbol/grid_index.ts +69 -40
- package/src/symbol/placement.ts +124 -95
- 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 +49 -2
- 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 +9 -9
- package/src/ui/camera.ts +26 -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 +5 -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 +3 -2
- 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 +87 -14
- package/src/ui/map.ts +138 -108
- 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 +214 -0
- 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/test/util.ts +14 -0
- 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
|
@@ -10,11 +10,11 @@ import type {FitBoundsOptions} from '../camera';
|
|
|
10
10
|
import type {IControl} from './control';
|
|
11
11
|
|
|
12
12
|
type GeolocateOptions = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
positionOptions?: PositionOptions;
|
|
14
|
+
fitBoundsOptions?: FitBoundsOptions;
|
|
15
|
+
trackUserLocation?: boolean;
|
|
16
|
+
showAccuracyCircle?: boolean;
|
|
17
|
+
showUserLocation?: boolean;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const defaultOptions: GeolocateOptions = {
|
|
@@ -173,29 +173,29 @@ class GeolocateControl extends Evented implements IControl {
|
|
|
173
173
|
|
|
174
174
|
_setErrorState() {
|
|
175
175
|
switch (this._watchState) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
176
|
+
case 'WAITING_ACTIVE':
|
|
177
|
+
this._watchState = 'ACTIVE_ERROR';
|
|
178
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
179
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error', 'mapboxgl-ctrl-geolocate-active-error');
|
|
180
|
+
break;
|
|
181
|
+
case 'ACTIVE_LOCK':
|
|
182
|
+
this._watchState = 'ACTIVE_ERROR';
|
|
183
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
184
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error', 'mapboxgl-ctrl-geolocate-active-error');
|
|
185
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
186
|
+
// turn marker grey
|
|
187
|
+
break;
|
|
188
|
+
case 'BACKGROUND':
|
|
189
|
+
this._watchState = 'BACKGROUND_ERROR';
|
|
190
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background', 'mapboxgl-ctrl-geolocate-background');
|
|
191
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error', 'mapboxgl-ctrl-geolocate-background-error');
|
|
192
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
193
|
+
// turn marker grey
|
|
194
|
+
break;
|
|
195
|
+
case 'ACTIVE_ERROR':
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
assert(false, `Unexpected watchState ${this._watchState}`);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -228,23 +228,23 @@ class GeolocateControl extends Evented implements IControl {
|
|
|
228
228
|
this._lastKnownPosition = position;
|
|
229
229
|
|
|
230
230
|
switch (this._watchState) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
231
|
+
case 'WAITING_ACTIVE':
|
|
232
|
+
case 'ACTIVE_LOCK':
|
|
233
|
+
case 'ACTIVE_ERROR':
|
|
234
|
+
this._watchState = 'ACTIVE_LOCK';
|
|
235
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
236
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error', 'mapboxgl-ctrl-geolocate-active-error');
|
|
237
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
238
|
+
break;
|
|
239
|
+
case 'BACKGROUND':
|
|
240
|
+
case 'BACKGROUND_ERROR':
|
|
241
|
+
this._watchState = 'BACKGROUND';
|
|
242
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
243
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error', 'mapboxgl-ctrl-geolocate-background-error');
|
|
244
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background', 'mapboxgl-ctrl-geolocate-background');
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
assert(false, `Unexpected watchState ${this._watchState}`);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -429,23 +429,23 @@ class GeolocateControl extends Evented implements IControl {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
432
|
+
* Programmatically request and move the map to the user's location.
|
|
433
|
+
*
|
|
434
|
+
* @returns {boolean} Returns `false` if called before control was added to a map, otherwise returns `true`.
|
|
435
|
+
* @example
|
|
436
|
+
* // Initialize the geolocate control.
|
|
437
|
+
* var geolocate = new maplibregl.GeolocateControl({
|
|
438
|
+
* positionOptions: {
|
|
439
|
+
* enableHighAccuracy: true
|
|
440
|
+
* },
|
|
441
|
+
* trackUserLocation: true
|
|
442
|
+
* });
|
|
443
|
+
* // Add the control to the map.
|
|
444
|
+
* map.addControl(geolocate);
|
|
445
|
+
* map.on('load', function() {
|
|
446
|
+
* geolocate.trigger();
|
|
447
|
+
* });
|
|
448
|
+
*/
|
|
449
449
|
trigger() {
|
|
450
450
|
if (!this._setup) {
|
|
451
451
|
warnOnce('Geolocate control triggered before added to a map');
|
|
@@ -454,53 +454,53 @@ class GeolocateControl extends Evented implements IControl {
|
|
|
454
454
|
if (this.options.trackUserLocation) {
|
|
455
455
|
// update watchState and do any outgoing state cleanup
|
|
456
456
|
switch (this._watchState) {
|
|
457
|
-
|
|
457
|
+
case 'OFF':
|
|
458
458
|
// turn on the Geolocate Control
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
459
|
+
this._watchState = 'WAITING_ACTIVE';
|
|
460
|
+
|
|
461
|
+
this.fire(new Event('trackuserlocationstart'));
|
|
462
|
+
break;
|
|
463
|
+
case 'WAITING_ACTIVE':
|
|
464
|
+
case 'ACTIVE_LOCK':
|
|
465
|
+
case 'ACTIVE_ERROR':
|
|
466
|
+
case 'BACKGROUND_ERROR':
|
|
467
467
|
// turn off the Geolocate Control
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
this.fire(new Event('trackuserlocationend'));
|
|
478
|
-
break;
|
|
479
|
-
case 'BACKGROUND':
|
|
480
|
-
this._watchState = 'ACTIVE_LOCK';
|
|
481
|
-
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background', 'mapboxgl-ctrl-geolocate-background');
|
|
482
|
-
// set camera to last known location
|
|
483
|
-
if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition);
|
|
468
|
+
numberOfWatches--;
|
|
469
|
+
noTimeout = false;
|
|
470
|
+
this._watchState = 'OFF';
|
|
471
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
472
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
473
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error', 'mapboxgl-ctrl-geolocate-active-error');
|
|
474
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background', 'mapboxgl-ctrl-geolocate-background');
|
|
475
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error', 'mapboxgl-ctrl-geolocate-background-error');
|
|
484
476
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
477
|
+
this.fire(new Event('trackuserlocationend'));
|
|
478
|
+
break;
|
|
479
|
+
case 'BACKGROUND':
|
|
480
|
+
this._watchState = 'ACTIVE_LOCK';
|
|
481
|
+
this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background', 'mapboxgl-ctrl-geolocate-background');
|
|
482
|
+
// set camera to last known location
|
|
483
|
+
if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition);
|
|
484
|
+
|
|
485
|
+
this.fire(new Event('trackuserlocationstart'));
|
|
486
|
+
break;
|
|
487
|
+
default:
|
|
488
|
+
assert(false, `Unexpected watchState ${this._watchState}`);
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
// incoming state setup
|
|
492
492
|
switch (this._watchState) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
493
|
+
case 'WAITING_ACTIVE':
|
|
494
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting', 'mapboxgl-ctrl-geolocate-waiting');
|
|
495
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
496
|
+
break;
|
|
497
|
+
case 'ACTIVE_LOCK':
|
|
498
|
+
this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active', 'mapboxgl-ctrl-geolocate-active');
|
|
499
|
+
break;
|
|
500
|
+
case 'OFF':
|
|
501
|
+
break;
|
|
502
|
+
default:
|
|
503
|
+
assert(false, `Unexpected watchState ${this._watchState}`);
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
// manage geolocation.watchPosition / geolocation.clearWatch
|
|
@@ -34,6 +34,7 @@ function createSource(options, logoRequired) {
|
|
|
34
34
|
_skuToken: '1234567890123',
|
|
35
35
|
canonicalizeTileset: tileJSON => tileJSON.tiles
|
|
36
36
|
},
|
|
37
|
+
style: {sourceCaches: {id: {clearTiles() {}}}},
|
|
37
38
|
transform: {angle: 0, pitch: 0, showCollisionBoxes: false},
|
|
38
39
|
_getMapId: () => 1
|
|
39
40
|
}as any as Map);
|
|
@@ -55,7 +56,7 @@ describe('LogoControl', () => {
|
|
|
55
56
|
const map = createMap(undefined, undefined);
|
|
56
57
|
map.on('load', () => {
|
|
57
58
|
expect(map.getContainer().querySelectorAll(
|
|
58
|
-
|
|
59
|
+
'.maplibregl-ctrl-bottom-left .maplibregl-ctrl-logo'
|
|
59
60
|
)).toHaveLength(1);
|
|
60
61
|
done();
|
|
61
62
|
});
|
|
@@ -65,7 +66,7 @@ describe('LogoControl', () => {
|
|
|
65
66
|
const map = createMap('top-left', undefined);
|
|
66
67
|
map.on('load', () => {
|
|
67
68
|
expect(map.getContainer().querySelectorAll(
|
|
68
|
-
|
|
69
|
+
'.maplibregl-ctrl-top-left .maplibregl-ctrl-logo'
|
|
69
70
|
)).toHaveLength(1);
|
|
70
71
|
done();
|
|
71
72
|
});
|
|
@@ -111,13 +112,13 @@ describe('LogoControl', () => {
|
|
|
111
112
|
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 255, configurable: true});
|
|
112
113
|
map.resize();
|
|
113
114
|
expect(
|
|
114
|
-
|
|
115
|
+
container.querySelectorAll('.maplibregl-ctrl-logo:not(.maplibregl-compact)')
|
|
115
116
|
).toHaveLength(1);
|
|
116
117
|
|
|
117
118
|
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 245, configurable: true});
|
|
118
119
|
map.resize();
|
|
119
120
|
expect(
|
|
120
|
-
|
|
121
|
+
container.querySelectorAll('.maplibregl-ctrl-logo.maplibregl-compact')
|
|
121
122
|
).toHaveLength(1);
|
|
122
123
|
});
|
|
123
124
|
|
|
@@ -8,9 +8,9 @@ import type Map from '../map';
|
|
|
8
8
|
import type {IControl} from './control';
|
|
9
9
|
|
|
10
10
|
type NavigationOptions = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
showCompass?: boolean;
|
|
12
|
+
showZoom?: boolean;
|
|
13
|
+
visualizePitch?: boolean;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const defaultOptions: NavigationOptions = {
|
|
@@ -12,7 +12,7 @@ describe('ScaleControl', () => {
|
|
|
12
12
|
map.addControl(new ScaleControl(undefined));
|
|
13
13
|
|
|
14
14
|
expect(
|
|
15
|
-
|
|
15
|
+
map.getContainer().querySelectorAll('.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale')
|
|
16
16
|
).toHaveLength(1);
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ describe('ScaleControl', () => {
|
|
|
21
21
|
map.addControl(new ScaleControl(undefined), 'top-left');
|
|
22
22
|
|
|
23
23
|
expect(
|
|
24
|
-
|
|
24
|
+
map.getContainer().querySelectorAll('.maplibregl-ctrl-top-left .maplibregl-ctrl-scale')
|
|
25
25
|
).toHaveLength(1);
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -7,8 +7,8 @@ import type {ControlPosition, IControl} from './control';
|
|
|
7
7
|
export type Unit = 'imperial' | 'metric' | 'nautical';
|
|
8
8
|
|
|
9
9
|
type ScaleOptions = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
unit?: Unit;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const defaultOptions: ScaleOptions = {
|
|
@@ -133,9 +133,9 @@ function getRoundNum(num) {
|
|
|
133
133
|
|
|
134
134
|
d = d >= 10 ? 10 :
|
|
135
135
|
d >= 5 ? 5 :
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
d >= 3 ? 3 :
|
|
137
|
+
d >= 2 ? 2 :
|
|
138
|
+
d >= 1 ? 1 : getDecimalRoundNum(d);
|
|
139
139
|
|
|
140
140
|
return pow10 * d;
|
|
141
141
|
}
|