maplibre-gl 2.1.0 → 2.1.4
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 +1537 -1011
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +83 -107
- package/postinstall.js +5 -0
- package/src/css/maplibre-gl.css +28 -28
- 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.test.ts +6 -4
- 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 +16 -5
- package/src/source/vector_tile_source.ts +2 -3
- 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 +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 +22 -15
- 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 +9 -9
- 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 +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 +26 -14
- package/src/ui/map.ts +107 -102
- 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
package/src/ui/map.ts
CHANGED
|
@@ -59,49 +59,49 @@ import type {ControlPosition, IControl} from './control/control';
|
|
|
59
59
|
/* eslint-enable no-use-before-define */
|
|
60
60
|
|
|
61
61
|
export type MapOptions = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
62
|
+
hash?: boolean | string;
|
|
63
|
+
interactive?: boolean;
|
|
64
|
+
container: HTMLElement | string;
|
|
65
|
+
bearingSnap?: number;
|
|
66
|
+
attributionControl?: boolean;
|
|
67
|
+
customAttribution?: string | Array<string>;
|
|
68
|
+
logoPosition?: ControlPosition;
|
|
69
|
+
failIfMajorPerformanceCaveat?: boolean;
|
|
70
|
+
preserveDrawingBuffer?: boolean;
|
|
71
|
+
antialias?: boolean;
|
|
72
|
+
refreshExpiredTiles?: boolean;
|
|
73
|
+
maxBounds?: LngLatBoundsLike;
|
|
74
|
+
scrollZoom?: boolean;
|
|
75
|
+
minZoom?: number | null;
|
|
76
|
+
maxZoom?: number | null;
|
|
77
|
+
minPitch?: number | null;
|
|
78
|
+
maxPitch?: number | null;
|
|
79
|
+
boxZoom?: boolean;
|
|
80
|
+
dragRotate?: boolean;
|
|
81
|
+
dragPan?: DragPanOptions | boolean;
|
|
82
|
+
keyboard?: boolean;
|
|
83
|
+
doubleClickZoom?: boolean;
|
|
84
|
+
touchZoomRotate?: boolean;
|
|
85
|
+
touchPitch?: boolean;
|
|
86
|
+
trackResize?: boolean;
|
|
87
|
+
center?: LngLatLike;
|
|
88
|
+
zoom?: number;
|
|
89
|
+
bearing?: number;
|
|
90
|
+
pitch?: number;
|
|
91
|
+
renderWorldCopies?: boolean;
|
|
92
|
+
maxTileCacheSize?: number;
|
|
93
|
+
transformRequest?: RequestTransformFunction;
|
|
94
|
+
locale?: any;
|
|
95
|
+
fadeDuration?: number;
|
|
96
|
+
crossSourceCollisions?: boolean;
|
|
97
|
+
collectResourceTiming?: boolean;
|
|
98
|
+
clickTolerance?: number;
|
|
99
|
+
bounds?: LngLatBoundsLike;
|
|
100
|
+
fitBoundsOptions?: Object;
|
|
101
|
+
localIdeographFontFamily?: string;
|
|
102
|
+
style: StyleSpecification | string;
|
|
103
|
+
pitchWithRotate?: boolean;
|
|
104
|
+
pixelRatio?: number;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
// See article here: https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585
|
|
@@ -212,19 +212,19 @@ const defaultOptions = {
|
|
|
212
212
|
* @param {boolean} [options.doubleClickZoom=true] If `true`, the "double click to zoom" interaction is enabled (see {@link DoubleClickZoomHandler}).
|
|
213
213
|
* @param {boolean|Object} [options.touchZoomRotate=true] If `true`, the "pinch to rotate and zoom" interaction is enabled. An `Object` value is passed as options to {@link TouchZoomRotateHandler#enable}.
|
|
214
214
|
* @param {boolean|Object} [options.touchPitch=true] If `true`, the "drag to pitch" interaction is enabled. An `Object` value is passed as options to {@link TouchPitchHandler#enable}.
|
|
215
|
-
* @param {boolean} [options.trackResize=true]
|
|
215
|
+
* @param {boolean} [options.trackResize=true] If `true`, the map will automatically resize when the browser window resizes.
|
|
216
216
|
* @param {LngLatLike} [options.center=[0, 0]] The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.
|
|
217
217
|
* @param {number} [options.zoom=0] The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.
|
|
218
218
|
* @param {number} [options.bearing=0] The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.
|
|
219
219
|
* @param {number} [options.pitch=0] The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
|
|
220
220
|
* @param {LngLatBoundsLike} [options.bounds] The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options.
|
|
221
221
|
* @param {Object} [options.fitBoundsOptions] A {@link Map#fitBounds} options object to use _only_ when fitting the initial `bounds` provided above.
|
|
222
|
-
* @param {boolean} [options.renderWorldCopies=true]
|
|
222
|
+
* @param {boolean} [options.renderWorldCopies=true] If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:
|
|
223
223
|
* - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire
|
|
224
224
|
* container, there will be blank space beyond 180 and -180 degrees longitude.
|
|
225
225
|
* - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the
|
|
226
226
|
* map and the other on the left edge of the map) at every zoom level.
|
|
227
|
-
* @param {number} [options.maxTileCacheSize=null]
|
|
227
|
+
* @param {number} [options.maxTileCacheSize=null] The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport.
|
|
228
228
|
* @param {string} [options.localIdeographFontFamily='sans-serif'] Defines a CSS
|
|
229
229
|
* font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.
|
|
230
230
|
* In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).
|
|
@@ -476,6 +476,9 @@ class Map extends Camera {
|
|
|
476
476
|
this.on('dataloading', (event: MapDataEvent) => {
|
|
477
477
|
this.fire(new Event(`${event.dataType}dataloading`, event));
|
|
478
478
|
});
|
|
479
|
+
this.on('dataabort', (event: MapDataEvent) => {
|
|
480
|
+
this.fire(new Event('sourcedataabort', event));
|
|
481
|
+
});
|
|
479
482
|
}
|
|
480
483
|
|
|
481
484
|
/*
|
|
@@ -618,7 +621,7 @@ class Map extends Camera {
|
|
|
618
621
|
* Sets the map's pixel ratio. This allows to override `devicePixelRatio`.
|
|
619
622
|
* After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio`
|
|
620
623
|
* and its height attribute will be `container.clientHeight * pixelRatio`.
|
|
621
|
-
* @param
|
|
624
|
+
* @param {number} pixelRatio The pixel ratio.
|
|
622
625
|
*/
|
|
623
626
|
setPixelRatio(pixelRatio: number) {
|
|
624
627
|
const [width, height] = this._containerDimensions();
|
|
@@ -1018,6 +1021,8 @@ class Map extends Camera {
|
|
|
1018
1021
|
* | [`styledataloading`](#map.event:styledataloading) | |
|
|
1019
1022
|
* | [`sourcedataloading`](#map.event:sourcedataloading) | |
|
|
1020
1023
|
* | [`styleimagemissing`](#map.event:styleimagemissing) | |
|
|
1024
|
+
* | [`dataabort`](#map.event:dataabort) | |
|
|
1025
|
+
* | [`sourcedataabort`](#map.event:sourcedataabort) | |
|
|
1021
1026
|
*
|
|
1022
1027
|
* @param {string | Listener} layerIdOrListener The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location
|
|
1023
1028
|
* is within a visible feature in this layer. The event will have a `features` property containing
|
|
@@ -1338,9 +1343,9 @@ class Map extends Camera {
|
|
|
1338
1343
|
*
|
|
1339
1344
|
*/
|
|
1340
1345
|
querySourceFeatures(sourceId: string, parameters?: {
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1346
|
+
sourceLayer: string;
|
|
1347
|
+
filter: Array<any>;
|
|
1348
|
+
validate?: boolean;
|
|
1344
1349
|
} | null) {
|
|
1345
1350
|
return this.style.querySourceFeatures(sourceId, parameters);
|
|
1346
1351
|
}
|
|
@@ -1372,7 +1377,7 @@ class Map extends Camera {
|
|
|
1372
1377
|
*
|
|
1373
1378
|
*/
|
|
1374
1379
|
setStyle(style: StyleSpecification | string | null, options?: {
|
|
1375
|
-
|
|
1380
|
+
diff?: boolean;
|
|
1376
1381
|
} & StyleOptions) {
|
|
1377
1382
|
options = extend({}, {localIdeographFontFamily: this._localIdeographFontFamily}, options);
|
|
1378
1383
|
|
|
@@ -1388,10 +1393,10 @@ class Map extends Camera {
|
|
|
1388
1393
|
/**
|
|
1389
1394
|
* Updates the requestManager's transform request with a new function
|
|
1390
1395
|
*
|
|
1391
|
-
*
|
|
1396
|
+
* @param transformRequest A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.
|
|
1392
1397
|
* Expected to return an object with a `url` property and optionally `headers` and `credentials` properties
|
|
1393
1398
|
*
|
|
1394
|
-
*
|
|
1399
|
+
* @returns {Map} `this`
|
|
1395
1400
|
*
|
|
1396
1401
|
* @example
|
|
1397
1402
|
* map.setTransformRequest((url: string, resourceType: string) => {});
|
|
@@ -1411,7 +1416,7 @@ class Map extends Camera {
|
|
|
1411
1416
|
}
|
|
1412
1417
|
|
|
1413
1418
|
_updateStyle(style: StyleSpecification | string | null, options?: {
|
|
1414
|
-
|
|
1419
|
+
diff?: boolean;
|
|
1415
1420
|
} & StyleOptions) {
|
|
1416
1421
|
if (this.style) {
|
|
1417
1422
|
this.style.setEventedParent(null);
|
|
@@ -1445,7 +1450,7 @@ class Map extends Camera {
|
|
|
1445
1450
|
}
|
|
1446
1451
|
|
|
1447
1452
|
_diffStyle(style: StyleSpecification | string, options?: {
|
|
1448
|
-
|
|
1453
|
+
diff?: boolean;
|
|
1449
1454
|
} & StyleOptions) {
|
|
1450
1455
|
if (typeof style === 'string') {
|
|
1451
1456
|
const url = style;
|
|
@@ -1463,7 +1468,7 @@ class Map extends Camera {
|
|
|
1463
1468
|
}
|
|
1464
1469
|
|
|
1465
1470
|
_updateDiff(style: StyleSpecification, options?: {
|
|
1466
|
-
|
|
1471
|
+
diff?: boolean;
|
|
1467
1472
|
} & StyleOptions) {
|
|
1468
1473
|
try {
|
|
1469
1474
|
if (this.style.setState(style)) {
|
|
@@ -1648,9 +1653,9 @@ class Map extends Camera {
|
|
|
1648
1653
|
* @param options Options object.
|
|
1649
1654
|
* @param options.pixelRatio The ratio of pixels in the image to physical pixels on the screen
|
|
1650
1655
|
* @param options.sdf Whether the image should be interpreted as an SDF image
|
|
1651
|
-
* @param options.content
|
|
1652
|
-
* @param options.stretchX
|
|
1653
|
-
* @param options.stretchY
|
|
1656
|
+
* @param options.content `[x1, y1, x2, y2]` If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`.
|
|
1657
|
+
* @param options.stretchX `[[x1, x2], ...]` If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally.
|
|
1658
|
+
* @param options.stretchY `[[y1, y2], ...]` If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically.
|
|
1654
1659
|
*
|
|
1655
1660
|
* @example
|
|
1656
1661
|
* // If the style's sprite does not already contain an image with ID 'cat',
|
|
@@ -1679,18 +1684,18 @@ class Map extends Camera {
|
|
|
1679
1684
|
* @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js-docs/example/add-image-generated/)
|
|
1680
1685
|
*/
|
|
1681
1686
|
addImage(id: string,
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1687
|
+
image: HTMLImageElement | ImageBitmap | ImageData | {
|
|
1688
|
+
width: number;
|
|
1689
|
+
height: number;
|
|
1690
|
+
data: Uint8Array | Uint8ClampedArray;
|
|
1691
|
+
} | StyleImageInterface,
|
|
1692
|
+
{
|
|
1693
|
+
pixelRatio = 1,
|
|
1694
|
+
sdf = false,
|
|
1695
|
+
stretchX,
|
|
1696
|
+
stretchY,
|
|
1697
|
+
content
|
|
1698
|
+
}: Partial<StyleImageMetadata> = {}) {
|
|
1694
1699
|
this._lazyInitEmptyStyle();
|
|
1695
1700
|
const version = 0;
|
|
1696
1701
|
|
|
@@ -1742,9 +1747,9 @@ class Map extends Camera {
|
|
|
1742
1747
|
*/
|
|
1743
1748
|
updateImage(id: string,
|
|
1744
1749
|
image: HTMLImageElement | ImageBitmap | ImageData | {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1750
|
+
width: number;
|
|
1751
|
+
height: number;
|
|
1752
|
+
data: Uint8Array | Uint8ClampedArray;
|
|
1748
1753
|
} | StyleImageInterface) {
|
|
1749
1754
|
|
|
1750
1755
|
const existingImage = this.style.getImage(id);
|
|
@@ -1781,7 +1786,7 @@ class Map extends Camera {
|
|
|
1781
1786
|
*
|
|
1782
1787
|
* @param id The ID of the image.
|
|
1783
1788
|
*
|
|
1784
|
-
* @returns {boolean}
|
|
1789
|
+
* @returns {boolean} A Boolean indicating whether the image exists.
|
|
1785
1790
|
* @example
|
|
1786
1791
|
* // Check if an image with the ID 'cat' exists in
|
|
1787
1792
|
* // the style's sprite.
|
|
@@ -1834,16 +1839,16 @@ class Map extends Camera {
|
|
|
1834
1839
|
}
|
|
1835
1840
|
|
|
1836
1841
|
/**
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1842
|
+
* Returns an Array of strings containing the IDs of all images currently available in the map.
|
|
1843
|
+
* This includes both images from the style's original sprite
|
|
1844
|
+
* and any images that have been added at runtime using {@link Map#addImage}.
|
|
1845
|
+
*
|
|
1846
|
+
* @returns {Array<string>} An Array of strings containing the names of all sprites/images currently available in the map.
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* var allImages = map.listImages();
|
|
1850
|
+
*
|
|
1851
|
+
*/
|
|
1847
1852
|
listImages() {
|
|
1848
1853
|
return this.style.listImages();
|
|
1849
1854
|
}
|
|
@@ -2207,9 +2212,9 @@ class Map extends Camera {
|
|
|
2207
2212
|
* @see [Create a hover effect](https://maplibre.org/maplibre-gl-js-docs/example/hover-styles/)
|
|
2208
2213
|
*/
|
|
2209
2214
|
setFeatureState(feature: {
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2215
|
+
source: string;
|
|
2216
|
+
sourceLayer?: string;
|
|
2217
|
+
id: string | number;
|
|
2213
2218
|
}, state: any) {
|
|
2214
2219
|
this.style.setFeatureState(feature, state);
|
|
2215
2220
|
return this._update();
|
|
@@ -2261,11 +2266,11 @@ class Map extends Camera {
|
|
|
2261
2266
|
* }, 'hover');
|
|
2262
2267
|
* });
|
|
2263
2268
|
*
|
|
2264
|
-
|
|
2269
|
+
*/
|
|
2265
2270
|
removeFeatureState(target: {
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2271
|
+
source: string;
|
|
2272
|
+
sourceLayer?: string;
|
|
2273
|
+
id?: string | number;
|
|
2269
2274
|
}, key?: string) {
|
|
2270
2275
|
this.style.removeFeatureState(target, key);
|
|
2271
2276
|
return this._update();
|
|
@@ -2301,11 +2306,11 @@ class Map extends Camera {
|
|
|
2301
2306
|
*
|
|
2302
2307
|
*/
|
|
2303
2308
|
getFeatureState(
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
+
feature: {
|
|
2310
|
+
source: string;
|
|
2311
|
+
sourceLayer?: string;
|
|
2312
|
+
id: string | number;
|
|
2313
|
+
}
|
|
2309
2314
|
): any {
|
|
2310
2315
|
return this.style.getFeatureState(feature);
|
|
2311
2316
|
}
|
|
@@ -2634,11 +2639,11 @@ class Map extends Camera {
|
|
|
2634
2639
|
}
|
|
2635
2640
|
|
|
2636
2641
|
/**
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
+
* Force a synchronous redraw of the map.
|
|
2643
|
+
* @example
|
|
2644
|
+
* map.redraw();
|
|
2645
|
+
* @returns {Map} `this`
|
|
2646
|
+
*/
|
|
2642
2647
|
redraw(): Map {
|
|
2643
2648
|
if (this.style) {
|
|
2644
2649
|
// cancel the scheduled update
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import simulate, {window} from '../../test/
|
|
1
|
+
import simulate, {window} from '../../test/unit/lib/simulate_interaction';
|
|
2
2
|
import StyleLayer from '../style/style_layer';
|
|
3
3
|
import {createMap, setPerformance, setWebGlContext} from '../util/test/util';
|
|
4
4
|
import {MapLayerEventType} from './events';
|
package/src/ui/marker.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Marker from './marker';
|
|
|
3
3
|
import Popup from './popup';
|
|
4
4
|
import LngLat from '../geo/lng_lat';
|
|
5
5
|
import Point from '@mapbox/point-geometry';
|
|
6
|
-
import simulate from '../../test/
|
|
6
|
+
import simulate from '../../test/unit/lib/simulate_interaction';
|
|
7
7
|
|
|
8
8
|
function createMap(options = {}) {
|
|
9
9
|
const container = window.document.createElement('div');
|
|
@@ -46,16 +46,16 @@ describe('marker', () => {
|
|
|
46
46
|
|
|
47
47
|
// initial dimensions of svg element
|
|
48
48
|
expect(
|
|
49
|
-
|
|
49
|
+
defaultMarker.getElement().children[0].getAttribute('height').includes('41')
|
|
50
50
|
).toBeTruthy();
|
|
51
51
|
expect(defaultMarker.getElement().children[0].getAttribute('width').includes('27')).toBeTruthy();
|
|
52
52
|
|
|
53
53
|
// (41 * 0.8) = 32.8, (27 * 0.8) = 21.6
|
|
54
54
|
expect(
|
|
55
|
-
|
|
55
|
+
smallerMarker.getElement().children[0].getAttribute('height').includes('32.8')
|
|
56
56
|
).toBeTruthy();
|
|
57
57
|
expect(
|
|
58
|
-
|
|
58
|
+
smallerMarker.getElement().children[0].getAttribute('width').includes('21.6')
|
|
59
59
|
).toBeTruthy();
|
|
60
60
|
|
|
61
61
|
// (41 * 2) = 82, (27 * 2) = 54
|
|
@@ -287,49 +287,49 @@ describe('marker', () => {
|
|
|
287
287
|
|
|
288
288
|
// marker should default to above since it has enough space
|
|
289
289
|
expect(
|
|
290
|
-
|
|
290
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom')
|
|
291
291
|
).toBeTruthy();
|
|
292
292
|
|
|
293
293
|
// move marker to the top forcing the popup to below
|
|
294
294
|
marker.setLngLat(map.unproject([mapHeight / 2, markerTop]));
|
|
295
295
|
expect(
|
|
296
|
-
|
|
296
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top')
|
|
297
297
|
).toBeTruthy();
|
|
298
298
|
|
|
299
299
|
// move marker to the right forcing the popup to the left
|
|
300
300
|
marker.setLngLat(map.unproject([mapHeight - markerRight, mapHeight / 2]));
|
|
301
301
|
expect(
|
|
302
|
-
|
|
302
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-right')
|
|
303
303
|
).toBeTruthy();
|
|
304
304
|
|
|
305
305
|
// move marker to the left forcing the popup to the right
|
|
306
306
|
marker.setLngLat(map.unproject([markerRight, mapHeight / 2]));
|
|
307
307
|
expect(
|
|
308
|
-
|
|
308
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-left')
|
|
309
309
|
).toBeTruthy();
|
|
310
310
|
|
|
311
311
|
// move marker to the top left forcing the popup to the bottom right
|
|
312
312
|
marker.setLngLat(map.unproject([markerRight, markerTop]));
|
|
313
313
|
expect(
|
|
314
|
-
|
|
314
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top-left')
|
|
315
315
|
).toBeTruthy();
|
|
316
316
|
|
|
317
317
|
// move marker to the top right forcing the popup to the bottom left
|
|
318
318
|
marker.setLngLat(map.unproject([mapHeight - markerRight, markerTop]));
|
|
319
319
|
expect(
|
|
320
|
-
|
|
320
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top-right')
|
|
321
321
|
).toBeTruthy();
|
|
322
322
|
|
|
323
323
|
// move marker to the bottom left forcing the popup to the top right
|
|
324
324
|
marker.setLngLat(map.unproject([markerRight, mapHeight]));
|
|
325
325
|
expect(
|
|
326
|
-
|
|
326
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom-left')
|
|
327
327
|
).toBeTruthy();
|
|
328
328
|
|
|
329
329
|
// move marker to the bottom right forcing the popup to the top left
|
|
330
330
|
marker.setLngLat(map.unproject([mapHeight - markerRight, mapHeight]));
|
|
331
331
|
expect(
|
|
332
|
-
|
|
332
|
+
marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom-right')
|
|
333
333
|
).toBeTruthy();
|
|
334
334
|
|
|
335
335
|
});
|
package/src/ui/marker.ts
CHANGED
|
@@ -13,16 +13,16 @@ import type {MapMouseEvent, MapTouchEvent} from './events';
|
|
|
13
13
|
import type {PointLike} from './camera';
|
|
14
14
|
|
|
15
15
|
type MarkerOptions = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
element?: HTMLElement;
|
|
17
|
+
offset?: PointLike;
|
|
18
|
+
anchor?: PositionAnchor;
|
|
19
|
+
color?: string;
|
|
20
|
+
scale?: number;
|
|
21
|
+
draggable?: boolean;
|
|
22
|
+
clickTolerance?: number;
|
|
23
|
+
rotation?: number;
|
|
24
|
+
rotationAlignment?: string;
|
|
25
|
+
pitchAlignment?: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -289,29 +289,29 @@ export default class Marker extends Evented {
|
|
|
289
289
|
* the marker on screen.
|
|
290
290
|
*
|
|
291
291
|
* @returns {LngLat} A {@link LngLat} describing the marker's location.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
292
|
+
* @example
|
|
293
|
+
* // Store the marker's longitude and latitude coordinates in a variable
|
|
294
|
+
* var lngLat = marker.getLngLat();
|
|
295
|
+
* // Print the marker's longitude and latitude values in the console
|
|
296
|
+
* console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )
|
|
297
|
+
* @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-marker/)
|
|
298
|
+
*/
|
|
299
299
|
getLngLat() {
|
|
300
300
|
return this._lngLat;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
304
|
+
* Set the marker's geographical position and move it.
|
|
305
|
+
* @param {LngLat} lnglat A {@link LngLat} describing where the marker should be located.
|
|
306
|
+
* @returns {Marker} `this`
|
|
307
|
+
* @example
|
|
308
|
+
* // Create a new marker, set the longitude and latitude, and add it to the map
|
|
309
|
+
* new maplibregl.Marker()
|
|
310
|
+
* .setLngLat([-65.017, -16.457])
|
|
311
|
+
* .addTo(map);
|
|
312
|
+
* @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js-docs/example/custom-marker-icons/)
|
|
313
|
+
* @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-marker/)
|
|
314
|
+
*/
|
|
315
315
|
setLngLat(lnglat: LngLatLike) {
|
|
316
316
|
this._lngLat = LngLat.convert(lnglat);
|
|
317
317
|
this._pos = null;
|
|
@@ -437,7 +437,7 @@ export default class Marker extends Evented {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
_update(e?: {
|
|
440
|
-
|
|
440
|
+
type: 'move' | 'moveend';
|
|
441
441
|
}) {
|
|
442
442
|
if (!this._map) return;
|
|
443
443
|
|
|
@@ -545,14 +545,14 @@ export default class Marker extends Evented {
|
|
|
545
545
|
// only fire dragend if it was preceded by at least one drag event
|
|
546
546
|
if (this._state === 'active') {
|
|
547
547
|
/**
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
548
|
+
* Fired when the marker is finished being dragged
|
|
549
|
+
*
|
|
550
|
+
* @event dragend
|
|
551
|
+
* @memberof Marker
|
|
552
|
+
* @instance
|
|
553
|
+
* @type {Object}
|
|
554
|
+
* @property {Marker} marker object that was dragged
|
|
555
|
+
*/
|
|
556
556
|
this.fire(new Event('dragend'));
|
|
557
557
|
}
|
|
558
558
|
|
package/src/ui/popup.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {createMap as globalCreateMap, setPerformance, setWebGlContext} from '../
|
|
|
2
2
|
import Popup, {Offset} from './popup';
|
|
3
3
|
import LngLat from '../geo/lng_lat';
|
|
4
4
|
import Point from '@mapbox/point-geometry';
|
|
5
|
-
import simulate from '../../test/
|
|
5
|
+
import simulate from '../../test/unit/lib/simulate_interaction';
|
|
6
6
|
import {PositionAnchor} from './anchor';
|
|
7
7
|
|
|
8
8
|
const containerWidth = 512;
|
|
@@ -91,7 +91,7 @@ describe('popup', () => {
|
|
|
91
91
|
.addTo(map);
|
|
92
92
|
|
|
93
93
|
expect(
|
|
94
|
-
|
|
94
|
+
popup.getElement().querySelectorAll('.maplibregl-popup-close-button')
|
|
95
95
|
).toHaveLength(0);
|
|
96
96
|
});
|
|
97
97
|
|
|
@@ -561,7 +561,7 @@ describe('popup', () => {
|
|
|
561
561
|
.addTo(map);
|
|
562
562
|
|
|
563
563
|
expect(
|
|
564
|
-
|
|
564
|
+
popup._container.classList.value
|
|
565
565
|
).toContain('maplibregl-popup-track-pointer');
|
|
566
566
|
});
|
|
567
567
|
|
|
@@ -574,7 +574,7 @@ describe('popup', () => {
|
|
|
574
574
|
popup.setText('Test');
|
|
575
575
|
|
|
576
576
|
expect(
|
|
577
|
-
|
|
577
|
+
popup._container.classList.value
|
|
578
578
|
).toContain('maplibregl-popup-track-pointer');
|
|
579
579
|
});
|
|
580
580
|
|
|
@@ -587,7 +587,7 @@ describe('popup', () => {
|
|
|
587
587
|
popup.trackPointer();
|
|
588
588
|
|
|
589
589
|
expect(
|
|
590
|
-
|
|
590
|
+
popup._container.classList.value
|
|
591
591
|
).toContain('maplibregl-popup-track-pointer');
|
|
592
592
|
});
|
|
593
593
|
|
|
@@ -601,7 +601,7 @@ describe('popup', () => {
|
|
|
601
601
|
|
|
602
602
|
expect(popup._pos).toEqual(map.project([0, 0]));
|
|
603
603
|
expect(
|
|
604
|
-
|
|
604
|
+
popup._container.classList.value
|
|
605
605
|
).not.toContain('maplibregl-popup-track-pointer');
|
|
606
606
|
});
|
|
607
607
|
|
|
@@ -613,7 +613,7 @@ describe('popup', () => {
|
|
|
613
613
|
.addTo(map);
|
|
614
614
|
|
|
615
615
|
expect(
|
|
616
|
-
|
|
616
|
+
popup._container.classList.value
|
|
617
617
|
).not.toContain('maplibregl-popup-track-pointer');
|
|
618
618
|
});
|
|
619
619
|
|
package/src/ui/popup.ts
CHANGED
|
@@ -21,18 +21,18 @@ const defaultOptions = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type Offset = number | PointLike | {
|
|
24
|
-
|
|
24
|
+
[_ in PositionAnchor]: PointLike;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export type PopupOptions = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
closeButton?: boolean;
|
|
29
|
+
closeOnClick?: boolean;
|
|
30
|
+
closeOnMove?: boolean;
|
|
31
|
+
focusAfterOpen?: boolean;
|
|
32
|
+
anchor?: PositionAnchor;
|
|
33
|
+
offset?: Offset;
|
|
34
|
+
className?: string;
|
|
35
|
+
maxWidth?: string;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const focusQuerySelector = [
|