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,4 +1,4 @@
|
|
|
1
|
-
import AttributionControl from './attribution_control';
|
|
1
|
+
import {AttributionControl} from './attribution_control';
|
|
2
2
|
import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util';
|
|
3
3
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
4
4
|
import {fakeServer} from 'nise';
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
2
|
-
import {bindAll} from '../../util/util';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
3
2
|
|
|
4
|
-
import type Map from '../map';
|
|
3
|
+
import type {Map} from '../map';
|
|
5
4
|
import type {ControlPosition, IControl} from './control';
|
|
6
|
-
|
|
5
|
+
import type {MapDataEvent} from '../events';
|
|
6
|
+
import type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
7
|
+
/**
|
|
8
|
+
* The {@link AttributionControl} options
|
|
9
|
+
*/
|
|
7
10
|
type AttributionOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* If `true`, the attribution control will always collapse when moving the map. If `false`,
|
|
13
|
+
* force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide.
|
|
14
|
+
* **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.**
|
|
15
|
+
*/
|
|
8
16
|
compact?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Attributions to show in addition to any other attributions.
|
|
19
|
+
*/
|
|
9
20
|
customAttribution?: string | Array<string>;
|
|
10
21
|
};
|
|
11
22
|
|
|
12
23
|
/**
|
|
13
24
|
* An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width).
|
|
14
|
-
*
|
|
15
|
-
* @implements {IControl}
|
|
16
|
-
* @param {AttributionOptions} [options]
|
|
17
|
-
* @param {boolean} [options.compact] If `true`, the attribution control will always collapse when moving the map. If `false`, force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide. **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.**
|
|
18
|
-
* @param {string | Array<string>} [options.customAttribution] String or strings to show in addition to any other attributions.
|
|
25
|
+
* @group Markers and Controls
|
|
19
26
|
* @example
|
|
20
|
-
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* let map = new maplibregl.Map({attributionControl: false})
|
|
21
29
|
* .addControl(new maplibregl.AttributionControl({
|
|
22
30
|
* compact: true
|
|
23
31
|
* }));
|
|
32
|
+
* ```
|
|
24
33
|
*/
|
|
25
|
-
class AttributionControl implements IControl {
|
|
34
|
+
export class AttributionControl implements IControl {
|
|
26
35
|
options: AttributionOptions;
|
|
27
36
|
_map: Map;
|
|
28
37
|
_compact: boolean;
|
|
@@ -34,21 +43,18 @@ class AttributionControl implements IControl {
|
|
|
34
43
|
styleId: string;
|
|
35
44
|
styleOwner: string;
|
|
36
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @param options - the attribution options
|
|
48
|
+
*/
|
|
37
49
|
constructor(options: AttributionOptions = {}) {
|
|
38
50
|
this.options = options;
|
|
39
|
-
|
|
40
|
-
bindAll([
|
|
41
|
-
'_toggleAttribution',
|
|
42
|
-
'_updateData',
|
|
43
|
-
'_updateCompact',
|
|
44
|
-
'_updateCompactMinimize'
|
|
45
|
-
], this);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
getDefaultPosition(): ControlPosition {
|
|
49
54
|
return 'bottom-right';
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
/** {@inheritDoc IControl.onAdd} */
|
|
52
58
|
onAdd(map: Map) {
|
|
53
59
|
this._map = map;
|
|
54
60
|
this._compact = this.options && this.options.compact;
|
|
@@ -70,6 +76,7 @@ class AttributionControl implements IControl {
|
|
|
70
76
|
return this._container;
|
|
71
77
|
}
|
|
72
78
|
|
|
79
|
+
/** {@inheritDoc IControl.onRemove} */
|
|
73
80
|
onRemove() {
|
|
74
81
|
DOM.remove(this._container);
|
|
75
82
|
|
|
@@ -90,7 +97,7 @@ class AttributionControl implements IControl {
|
|
|
90
97
|
element.setAttribute('aria-label', str);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
_toggleAttribution() {
|
|
100
|
+
_toggleAttribution = () => {
|
|
94
101
|
if (this._container.classList.contains('maplibregl-compact')) {
|
|
95
102
|
if (this._container.classList.contains('maplibregl-compact-show')) {
|
|
96
103
|
this._container.setAttribute('open', '');
|
|
@@ -100,13 +107,13 @@ class AttributionControl implements IControl {
|
|
|
100
107
|
this._container.removeAttribute('open');
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
|
-
}
|
|
110
|
+
};
|
|
104
111
|
|
|
105
|
-
_updateData(e:
|
|
112
|
+
_updateData = (e: MapDataEvent) => {
|
|
106
113
|
if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) {
|
|
107
114
|
this._updateAttributions();
|
|
108
115
|
}
|
|
109
|
-
}
|
|
116
|
+
};
|
|
110
117
|
|
|
111
118
|
_updateAttributions() {
|
|
112
119
|
if (!this._map.style) return;
|
|
@@ -125,7 +132,7 @@ class AttributionControl implements IControl {
|
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
if (this._map.style.stylesheet) {
|
|
128
|
-
const stylesheet
|
|
135
|
+
const stylesheet = this._map.style.stylesheet as StyleSpecification & { owner: string; id: string };
|
|
129
136
|
this.styleOwner = stylesheet.owner;
|
|
130
137
|
this.styleId = stylesheet.id;
|
|
131
138
|
}
|
|
@@ -171,7 +178,7 @@ class AttributionControl implements IControl {
|
|
|
171
178
|
this._editLink = null;
|
|
172
179
|
}
|
|
173
180
|
|
|
174
|
-
_updateCompact() {
|
|
181
|
+
_updateCompact = () => {
|
|
175
182
|
if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {
|
|
176
183
|
if (this._compact === false) {
|
|
177
184
|
this._container.setAttribute('open', '');
|
|
@@ -185,16 +192,13 @@ class AttributionControl implements IControl {
|
|
|
185
192
|
this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show');
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
|
-
}
|
|
195
|
+
};
|
|
189
196
|
|
|
190
|
-
_updateCompactMinimize() {
|
|
197
|
+
_updateCompactMinimize = () => {
|
|
191
198
|
if (this._container.classList.contains('maplibregl-compact')) {
|
|
192
199
|
if (this._container.classList.contains('maplibregl-compact-show')) {
|
|
193
200
|
this._container.classList.remove('maplibregl-compact-show');
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
203
|
+
};
|
|
198
204
|
}
|
|
199
|
-
|
|
200
|
-
export default AttributionControl;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type {Map} from '../map';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A position defintion for the control to be placed, can be in one of the corners of the map.
|
|
5
|
+
* When two or more controls are places in the same location they are stacked toward the center of the map.
|
|
6
|
+
*/
|
|
1
7
|
export type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
2
|
-
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* Interface for interactive controls added to the map. This is a
|
|
5
11
|
* specification for implementers to model: it is not
|
|
@@ -10,9 +16,9 @@ import type Map from '../map';
|
|
|
10
16
|
* default control styling, add the `maplibregl-ctrl` class to your control's
|
|
11
17
|
* node.
|
|
12
18
|
*
|
|
13
|
-
* @interface IControl
|
|
14
19
|
* @example
|
|
15
|
-
*
|
|
20
|
+
* Control implemented as ES6 class
|
|
21
|
+
* ```ts
|
|
16
22
|
* class HelloWorldControl {
|
|
17
23
|
* onAdd(map) {
|
|
18
24
|
* this._map = map;
|
|
@@ -43,6 +49,7 @@ import type Map from '../map';
|
|
|
43
49
|
* this._container.parentNode.removeChild(this._container);
|
|
44
50
|
* this._map = undefined;
|
|
45
51
|
* };
|
|
52
|
+
* ```
|
|
46
53
|
*/
|
|
47
54
|
export interface IControl {
|
|
48
55
|
/**
|
|
@@ -50,12 +57,8 @@ export interface IControl {
|
|
|
50
57
|
* and resources. This method is called by {@link Map#addControl}
|
|
51
58
|
* internally.
|
|
52
59
|
*
|
|
53
|
-
* @
|
|
54
|
-
* @
|
|
55
|
-
* @instance
|
|
56
|
-
* @name onAdd
|
|
57
|
-
* @param {Map} map the Map this control will be added to
|
|
58
|
-
* @returns {HTMLElement} The control's container element. This should
|
|
60
|
+
* @param map - the Map this control will be added to
|
|
61
|
+
* @returns The control's container element. This should
|
|
59
62
|
* be created by the control and returned by onAdd without being attached
|
|
60
63
|
* to the DOM: the map will insert the control's element into the DOM
|
|
61
64
|
* as necessary.
|
|
@@ -66,12 +69,7 @@ export interface IControl {
|
|
|
66
69
|
* and resources. This method is called by {@link Map#removeControl}
|
|
67
70
|
* internally.
|
|
68
71
|
*
|
|
69
|
-
* @
|
|
70
|
-
* @memberof IControl
|
|
71
|
-
* @instance
|
|
72
|
-
* @name onRemove
|
|
73
|
-
* @param {Map} map the Map this control will be removed from
|
|
74
|
-
* @returns {undefined} there is no required return value for this method
|
|
72
|
+
* @param map - the Map this control will be removed from
|
|
75
73
|
*/
|
|
76
74
|
onRemove(map: Map): void;
|
|
77
75
|
/**
|
|
@@ -80,11 +78,7 @@ export interface IControl {
|
|
|
80
78
|
* parameter, the value returned by getDefaultPosition will be used as the
|
|
81
79
|
* control's position.
|
|
82
80
|
*
|
|
83
|
-
* @
|
|
84
|
-
* @memberof IControl
|
|
85
|
-
* @instance
|
|
86
|
-
* @name getDefaultPosition
|
|
87
|
-
* @returns {ControlPosition} a control position, one of the values valid in addControl.
|
|
81
|
+
* @returns a control position, one of the values valid in addControl.
|
|
88
82
|
*/
|
|
89
83
|
readonly getDefaultPosition?: () => ControlPosition;
|
|
90
84
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
2
2
|
|
|
3
3
|
import {warnOnce} from '../../util/util';
|
|
4
4
|
|
|
5
5
|
import {Event, Evented} from '../../util/evented';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Map, GestureOptions} from '../map';
|
|
7
7
|
import type {IControl} from './control';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The {@link FullscreenControl} options
|
|
11
|
+
*/
|
|
9
12
|
type FullscreenOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.
|
|
15
|
+
*/
|
|
10
16
|
container?: HTMLElement;
|
|
11
17
|
};
|
|
12
18
|
|
|
@@ -16,32 +22,22 @@ type FullscreenOptions = {
|
|
|
16
22
|
* The map's `cooperativeGestures` option is temporarily disabled while the map
|
|
17
23
|
* is in fullscreen mode, and is restored when the map exist fullscreen mode.
|
|
18
24
|
*
|
|
19
|
-
* @
|
|
20
|
-
* @param
|
|
21
|
-
* @param {HTMLElement} [options.container] `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.
|
|
25
|
+
* @group Markers and Controls
|
|
26
|
+
* @param options - the full screen control options
|
|
22
27
|
*
|
|
23
28
|
* @example
|
|
29
|
+
* ```ts
|
|
24
30
|
* map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')}));
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Fired when fullscreen mode has started
|
|
31
|
+
* ```
|
|
32
|
+
* @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/)
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Fired when fullscreen mode has ended
|
|
34
|
+
* ### Events
|
|
35
|
+
*
|
|
36
|
+
* @event `fullscreenstart` - Fired when fullscreen mode has started
|
|
38
37
|
*
|
|
39
|
-
* @event fullscreenend
|
|
40
|
-
* @memberof FullscreenControl
|
|
41
|
-
* @instance
|
|
38
|
+
* @event `fullscreenend` - Fired when fullscreen mode has ended
|
|
42
39
|
*/
|
|
43
|
-
|
|
44
|
-
class FullscreenControl extends Evented implements IControl {
|
|
40
|
+
export class FullscreenControl extends Evented implements IControl {
|
|
45
41
|
_map: Map;
|
|
46
42
|
_controlContainer: HTMLElement;
|
|
47
43
|
_fullscreen: boolean;
|
|
@@ -73,7 +69,8 @@ class FullscreenControl extends Evented implements IControl {
|
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
onAdd
|
|
72
|
+
/** {@inheritDoc IControl.onAdd} */
|
|
73
|
+
onAdd(map: Map): HTMLElement {
|
|
77
74
|
this._map = map;
|
|
78
75
|
if (!this._container) this._container = this._map.getContainer();
|
|
79
76
|
this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');
|
|
@@ -81,6 +78,7 @@ class FullscreenControl extends Evented implements IControl {
|
|
|
81
78
|
return this._controlContainer;
|
|
82
79
|
}
|
|
83
80
|
|
|
81
|
+
/** {@inheritDoc IControl.onRemove} */
|
|
84
82
|
onRemove() {
|
|
85
83
|
DOM.remove(this._controlContainer);
|
|
86
84
|
this._map = null;
|
|
@@ -185,6 +183,3 @@ class FullscreenControl extends Evented implements IControl {
|
|
|
185
183
|
this._map.resize();
|
|
186
184
|
}
|
|
187
185
|
}
|
|
188
|
-
|
|
189
|
-
export default FullscreenControl;
|
|
190
|
-
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import geolocation from 'mock-geolocation';
|
|
2
|
-
import LngLatBounds from '../../geo/lng_lat_bounds';
|
|
2
|
+
import {LngLatBounds} from '../../geo/lng_lat_bounds';
|
|
3
3
|
import {createMap, beforeMapTest} from '../../util/test/util';
|
|
4
|
-
import GeolocateControl from './geolocate_control';
|
|
4
|
+
import {GeolocateControl} from './geolocate_control';
|
|
5
5
|
jest.mock('../../util/geolocation_support', () => (
|
|
6
6
|
{
|
|
7
7
|
checkGeolocationSupport: jest.fn()
|
|
8
8
|
}
|
|
9
9
|
));
|
|
10
10
|
import {checkGeolocationSupport} from '../../util/geolocation_support';
|
|
11
|
-
import type LngLat from '../../geo/lng_lat';
|
|
11
|
+
import type {LngLat} from '../../geo/lng_lat';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Convert the coordinates of a LngLat object to a fixed number of digits
|
|
15
|
-
* @param lngLat
|
|
16
|
-
* @param digits
|
|
15
|
+
* @param lngLat - the location
|
|
16
|
+
* @param digits - digits the number of digits to set
|
|
17
17
|
* @returns a string representation of the object with the required number of digits
|
|
18
18
|
*/
|
|
19
19
|
function lngLatAsFixed(lngLat: LngLat, digits: number): {lat: string; lng: string} {
|