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
package/src/ui/marker.ts
CHANGED
|
@@ -1,59 +1,113 @@
|
|
|
1
|
-
import DOM from '../util/dom';
|
|
2
|
-
import LngLat from '../geo/lng_lat';
|
|
1
|
+
import {DOM} from '../util/dom';
|
|
2
|
+
import {LngLat} from '../geo/lng_lat';
|
|
3
3
|
import Point from '@mapbox/point-geometry';
|
|
4
|
-
import smartWrap from '../util/smart_wrap';
|
|
5
|
-
import {bindAll, extend} from '../util/util';
|
|
4
|
+
import {smartWrap} from '../util/smart_wrap';
|
|
6
5
|
import {anchorTranslate, applyAnchorClass} from './anchor';
|
|
7
6
|
import type {PositionAnchor} from './anchor';
|
|
8
7
|
import {Event, Evented} from '../util/evented';
|
|
9
|
-
import type Map from './map';
|
|
10
|
-
import Popup,
|
|
8
|
+
import type {Map} from './map';
|
|
9
|
+
import {Popup, Offset} from './popup';
|
|
11
10
|
import type {LngLatLike} from '../geo/lng_lat';
|
|
12
11
|
import type {MapMouseEvent, MapTouchEvent} from './events';
|
|
13
12
|
import type {PointLike} from './camera';
|
|
14
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Alignment options of rotation and pitch
|
|
16
|
+
*/
|
|
17
|
+
type Alignment = 'map' | 'viewport' | 'auto';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The {@link Marker} options object
|
|
21
|
+
*/
|
|
15
22
|
type MarkerOptions = {
|
|
23
|
+
/**
|
|
24
|
+
* DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.
|
|
25
|
+
*/
|
|
16
26
|
element?: HTMLElement;
|
|
27
|
+
/**
|
|
28
|
+
* Space-separated CSS class names to add to marker element.
|
|
29
|
+
*/
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
|
|
33
|
+
*/
|
|
17
34
|
offset?: PointLike;
|
|
35
|
+
/**
|
|
36
|
+
* A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.
|
|
37
|
+
* Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.
|
|
38
|
+
* @defaultValue 'center'
|
|
39
|
+
* */
|
|
18
40
|
anchor?: PositionAnchor;
|
|
41
|
+
/**
|
|
42
|
+
* The color to use for the default marker if options.element is not provided. The default is light blue.
|
|
43
|
+
* @defaultValue '#3FB1CE'
|
|
44
|
+
*/
|
|
19
45
|
color?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.
|
|
48
|
+
* @defaultValue 1
|
|
49
|
+
*/
|
|
20
50
|
scale?: number;
|
|
51
|
+
/**
|
|
52
|
+
* A boolean indicating whether or not a marker is able to be dragged to a new position on the map.
|
|
53
|
+
* @defaultValue false
|
|
54
|
+
*/
|
|
21
55
|
draggable?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.
|
|
58
|
+
* @defaultValue 0
|
|
59
|
+
*/
|
|
22
60
|
clickTolerance?: number;
|
|
61
|
+
/**
|
|
62
|
+
* The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.
|
|
63
|
+
* @defaultValue 0
|
|
64
|
+
*/
|
|
23
65
|
rotation?: number;
|
|
24
|
-
|
|
25
|
-
|
|
66
|
+
/**
|
|
67
|
+
* `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.
|
|
68
|
+
* @defaultValue 'auto'
|
|
69
|
+
*/
|
|
70
|
+
rotationAlignment?: Alignment;
|
|
71
|
+
/**
|
|
72
|
+
* `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.
|
|
73
|
+
* @defaultValue 'auto'
|
|
74
|
+
*/
|
|
75
|
+
pitchAlignment?: Alignment;
|
|
26
76
|
};
|
|
27
77
|
|
|
28
78
|
/**
|
|
29
79
|
* Creates a marker component
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
* Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.
|
|
34
|
-
* @param {PointLike} [options.offset] The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
|
|
35
|
-
* @param {string} [options.color='#3FB1CE'] The color to use for the default marker if options.element is not provided. The default is light blue.
|
|
36
|
-
* @param {number} [options.scale=1] The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.
|
|
37
|
-
* @param {boolean} [options.draggable=false] A boolean indicating whether or not a marker is able to be dragged to a new position on the map.
|
|
38
|
-
* @param {number} [options.clickTolerance=0] The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.
|
|
39
|
-
* @param {number} [options.rotation=0] The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.
|
|
40
|
-
* @param {string} [options.pitchAlignment='auto'] `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.
|
|
41
|
-
* @param {string} [options.rotationAlignment='auto'] `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.
|
|
80
|
+
*
|
|
81
|
+
* @group Markers and Controls
|
|
82
|
+
*
|
|
42
83
|
* @example
|
|
43
|
-
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* let marker = new maplibregl.Marker()
|
|
44
86
|
* .setLngLat([30.5, 50.5])
|
|
45
87
|
* .addTo(map);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
46
90
|
* @example
|
|
47
|
-
*
|
|
48
|
-
*
|
|
91
|
+
* Set options
|
|
92
|
+
* ```ts
|
|
93
|
+
* let marker = new maplibregl.Marker({
|
|
49
94
|
* color: "#FFFFFF",
|
|
50
95
|
* draggable: true
|
|
51
96
|
* }).setLngLat([30.5, 50.5])
|
|
52
97
|
* .addTo(map);
|
|
53
|
-
*
|
|
54
|
-
* @see [
|
|
98
|
+
* ```
|
|
99
|
+
* @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)
|
|
100
|
+
* @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
|
|
101
|
+
*
|
|
102
|
+
* ### Events
|
|
103
|
+
*
|
|
104
|
+
* @event `dragstart` Fired when dragging starts, `marker` object that is being dragged
|
|
105
|
+
*
|
|
106
|
+
* @event `drag` Fired while dragging. `marker` object that is being dragged
|
|
107
|
+
*
|
|
108
|
+
* @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged
|
|
55
109
|
*/
|
|
56
|
-
export
|
|
110
|
+
export class Marker extends Evented {
|
|
57
111
|
_map: Map;
|
|
58
112
|
_anchor: PositionAnchor;
|
|
59
113
|
_offset: Point;
|
|
@@ -71,27 +125,16 @@ export default class Marker extends Evented {
|
|
|
71
125
|
_positionDelta: Point;
|
|
72
126
|
_pointerdownPos: Point;
|
|
73
127
|
_rotation: number;
|
|
74
|
-
_pitchAlignment:
|
|
75
|
-
_rotationAlignment:
|
|
128
|
+
_pitchAlignment: Alignment;
|
|
129
|
+
_rotationAlignment: Alignment;
|
|
76
130
|
_originalTabIndex: string; // original tabindex of _element
|
|
77
131
|
_opacityTimeout: ReturnType<typeof setTimeout>;
|
|
78
132
|
|
|
79
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @param options - the options
|
|
135
|
+
*/
|
|
136
|
+
constructor(options?: MarkerOptions) {
|
|
80
137
|
super();
|
|
81
|
-
// For backward compatibility -- the constructor used to accept the element as a
|
|
82
|
-
// required first argument, before it was made optional.
|
|
83
|
-
if (options instanceof HTMLElement || legacyOptions) {
|
|
84
|
-
options = extend({element: options}, legacyOptions);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
bindAll([
|
|
88
|
-
'_update',
|
|
89
|
-
'_onMove',
|
|
90
|
-
'_onUp',
|
|
91
|
-
'_addDragHandler',
|
|
92
|
-
'_onMapClick',
|
|
93
|
-
'_onKeyPress'
|
|
94
|
-
], this);
|
|
95
138
|
|
|
96
139
|
this._anchor = options && options.anchor || 'center';
|
|
97
140
|
this._color = options && options.color || '#3FB1CE';
|
|
@@ -228,19 +271,27 @@ export default class Marker extends Evented {
|
|
|
228
271
|
});
|
|
229
272
|
applyAnchorClass(this._element, this._anchor, 'marker');
|
|
230
273
|
|
|
274
|
+
if (options && options.className) {
|
|
275
|
+
for (const name of options.className.split(' ')) {
|
|
276
|
+
this._element.classList.add(name);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
231
280
|
this._popup = null;
|
|
232
281
|
}
|
|
233
282
|
|
|
234
283
|
/**
|
|
235
284
|
* Attaches the `Marker` to a `Map` object.
|
|
236
|
-
* @param
|
|
237
|
-
* @returns
|
|
285
|
+
* @param map - The MapLibre GL JS map to add the marker to.
|
|
286
|
+
* @returns `this`
|
|
238
287
|
* @example
|
|
239
|
-
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* let marker = new maplibregl.Marker()
|
|
240
290
|
* .setLngLat([30.5, 50.5])
|
|
241
291
|
* .addTo(map); // add the marker to the map
|
|
292
|
+
* ```
|
|
242
293
|
*/
|
|
243
|
-
addTo(map: Map) {
|
|
294
|
+
addTo(map: Map): this {
|
|
244
295
|
this.remove();
|
|
245
296
|
this._map = map;
|
|
246
297
|
map.getCanvasContainer().appendChild(this._element);
|
|
@@ -260,11 +311,13 @@ export default class Marker extends Evented {
|
|
|
260
311
|
/**
|
|
261
312
|
* Removes the marker from a map
|
|
262
313
|
* @example
|
|
263
|
-
*
|
|
314
|
+
* ```ts
|
|
315
|
+
* let marker = new maplibregl.Marker().addTo(map);
|
|
264
316
|
* marker.remove();
|
|
265
|
-
*
|
|
317
|
+
* ```
|
|
318
|
+
* @returns `this`
|
|
266
319
|
*/
|
|
267
|
-
remove() {
|
|
320
|
+
remove(): this {
|
|
268
321
|
if (this._opacityTimeout) {
|
|
269
322
|
clearTimeout(this._opacityTimeout);
|
|
270
323
|
delete this._opacityTimeout;
|
|
@@ -293,31 +346,35 @@ export default class Marker extends Evented {
|
|
|
293
346
|
* set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep
|
|
294
347
|
* the marker on screen.
|
|
295
348
|
*
|
|
296
|
-
* @returns
|
|
349
|
+
* @returns A {@link LngLat} describing the marker's location.
|
|
297
350
|
* @example
|
|
351
|
+
* ```ts
|
|
298
352
|
* // Store the marker's longitude and latitude coordinates in a variable
|
|
299
|
-
*
|
|
353
|
+
* let lngLat = marker.getLngLat();
|
|
300
354
|
* // Print the marker's longitude and latitude values in the console
|
|
301
355
|
* console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )
|
|
302
|
-
*
|
|
356
|
+
* ```
|
|
357
|
+
* @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
|
|
303
358
|
*/
|
|
304
|
-
getLngLat() {
|
|
359
|
+
getLngLat(): LngLat {
|
|
305
360
|
return this._lngLat;
|
|
306
361
|
}
|
|
307
362
|
|
|
308
363
|
/**
|
|
309
364
|
* Set the marker's geographical position and move it.
|
|
310
|
-
* @param
|
|
311
|
-
* @returns
|
|
365
|
+
* @param lnglat - A {@link LngLat} describing where the marker should be located.
|
|
366
|
+
* @returns `this`
|
|
312
367
|
* @example
|
|
313
|
-
*
|
|
368
|
+
* Create a new marker, set the longitude and latitude, and add it to the map
|
|
369
|
+
* ```ts
|
|
314
370
|
* new maplibregl.Marker()
|
|
315
371
|
* .setLngLat([-65.017, -16.457])
|
|
316
372
|
* .addTo(map);
|
|
317
|
-
*
|
|
318
|
-
* @see [
|
|
373
|
+
* ```
|
|
374
|
+
* @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)
|
|
375
|
+
* @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
|
|
319
376
|
*/
|
|
320
|
-
setLngLat(lnglat: LngLatLike) {
|
|
377
|
+
setLngLat(lnglat: LngLatLike): this {
|
|
321
378
|
this._lngLat = LngLat.convert(lnglat);
|
|
322
379
|
this._pos = null;
|
|
323
380
|
if (this._popup) this._popup.setLngLat(this._lngLat);
|
|
@@ -327,25 +384,27 @@ export default class Marker extends Evented {
|
|
|
327
384
|
|
|
328
385
|
/**
|
|
329
386
|
* Returns the `Marker`'s HTML element.
|
|
330
|
-
* @returns
|
|
387
|
+
* @returns element
|
|
331
388
|
*/
|
|
332
|
-
getElement() {
|
|
389
|
+
getElement(): HTMLElement {
|
|
333
390
|
return this._element;
|
|
334
391
|
}
|
|
335
392
|
|
|
336
393
|
/**
|
|
337
394
|
* Binds a {@link Popup} to the {@link Marker}.
|
|
338
|
-
* @param popup An instance of the {@link Popup} class. If undefined or null, any popup
|
|
395
|
+
* @param popup - An instance of the {@link Popup} class. If undefined or null, any popup
|
|
339
396
|
* set on this {@link Marker} instance is unset.
|
|
340
|
-
* @returns
|
|
397
|
+
* @returns `this`
|
|
341
398
|
* @example
|
|
342
|
-
*
|
|
399
|
+
* ```ts
|
|
400
|
+
* let marker = new maplibregl.Marker()
|
|
343
401
|
* .setLngLat([0, 0])
|
|
344
402
|
* .setPopup(new maplibregl.Popup().setHTML("<h1>Hello World!</h1>")) // add popup
|
|
345
403
|
* .addTo(map);
|
|
346
|
-
*
|
|
404
|
+
* ```
|
|
405
|
+
* @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)
|
|
347
406
|
*/
|
|
348
|
-
setPopup(popup?: Popup | null) {
|
|
407
|
+
setPopup(popup?: Popup | null): this {
|
|
349
408
|
if (this._popup) {
|
|
350
409
|
this._popup.remove();
|
|
351
410
|
this._popup = null;
|
|
@@ -385,7 +444,7 @@ export default class Marker extends Evented {
|
|
|
385
444
|
return this;
|
|
386
445
|
}
|
|
387
446
|
|
|
388
|
-
_onKeyPress(e: KeyboardEvent) {
|
|
447
|
+
_onKeyPress = (e: KeyboardEvent) => {
|
|
389
448
|
const code = e.code;
|
|
390
449
|
const legacyCode = e.charCode || e.keyCode;
|
|
391
450
|
|
|
@@ -395,44 +454,48 @@ export default class Marker extends Evented {
|
|
|
395
454
|
) {
|
|
396
455
|
this.togglePopup();
|
|
397
456
|
}
|
|
398
|
-
}
|
|
457
|
+
};
|
|
399
458
|
|
|
400
|
-
_onMapClick(e: MapMouseEvent) {
|
|
459
|
+
_onMapClick = (e: MapMouseEvent) => {
|
|
401
460
|
const targetElement = e.originalEvent.target;
|
|
402
461
|
const element = this._element;
|
|
403
462
|
|
|
404
463
|
if (this._popup && (targetElement === element || element.contains(targetElement as any))) {
|
|
405
464
|
this.togglePopup();
|
|
406
465
|
}
|
|
407
|
-
}
|
|
466
|
+
};
|
|
408
467
|
|
|
409
468
|
/**
|
|
410
469
|
* Returns the {@link Popup} instance that is bound to the {@link Marker}.
|
|
411
|
-
* @returns
|
|
470
|
+
* @returns popup
|
|
412
471
|
* @example
|
|
413
|
-
*
|
|
472
|
+
* ```ts
|
|
473
|
+
* let marker = new maplibregl.Marker()
|
|
414
474
|
* .setLngLat([0, 0])
|
|
415
475
|
* .setPopup(new maplibregl.Popup().setHTML("<h1>Hello World!</h1>"))
|
|
416
476
|
* .addTo(map);
|
|
417
477
|
*
|
|
418
478
|
* console.log(marker.getPopup()); // return the popup instance
|
|
479
|
+
* ```
|
|
419
480
|
*/
|
|
420
|
-
getPopup() {
|
|
481
|
+
getPopup(): Popup {
|
|
421
482
|
return this._popup;
|
|
422
483
|
}
|
|
423
484
|
|
|
424
485
|
/**
|
|
425
486
|
* Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}.
|
|
426
|
-
* @returns
|
|
487
|
+
* @returns `this`
|
|
427
488
|
* @example
|
|
428
|
-
*
|
|
489
|
+
* ```ts
|
|
490
|
+
* let marker = new maplibregl.Marker()
|
|
429
491
|
* .setLngLat([0, 0])
|
|
430
492
|
* .setPopup(new maplibregl.Popup().setHTML("<h1>Hello World!</h1>"))
|
|
431
493
|
* .addTo(map);
|
|
432
494
|
*
|
|
433
495
|
* marker.togglePopup(); // toggle popup open or closed
|
|
496
|
+
* ```
|
|
434
497
|
*/
|
|
435
|
-
togglePopup() {
|
|
498
|
+
togglePopup(): this {
|
|
436
499
|
const popup = this._popup;
|
|
437
500
|
|
|
438
501
|
if (!popup) return this;
|
|
@@ -441,9 +504,7 @@ export default class Marker extends Evented {
|
|
|
441
504
|
return this;
|
|
442
505
|
}
|
|
443
506
|
|
|
444
|
-
_update(e?: {
|
|
445
|
-
type: 'move' | 'moveend';
|
|
446
|
-
}) {
|
|
507
|
+
_update = (e?: { type: 'move' | 'moveend' }) => {
|
|
447
508
|
if (!this._map) return;
|
|
448
509
|
|
|
449
510
|
if (this._map.transform.renderWorldCopies) {
|
|
@@ -483,28 +544,75 @@ export default class Marker extends Evented {
|
|
|
483
544
|
this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0';
|
|
484
545
|
this._opacityTimeout = null;
|
|
485
546
|
}, 100);
|
|
486
|
-
}
|
|
547
|
+
};
|
|
487
548
|
|
|
488
549
|
/**
|
|
489
550
|
* Get the marker's offset.
|
|
490
|
-
* @returns
|
|
551
|
+
* @returns The marker's screen coordinates in pixels.
|
|
491
552
|
*/
|
|
492
|
-
getOffset() {
|
|
553
|
+
getOffset(): Point {
|
|
493
554
|
return this._offset;
|
|
494
555
|
}
|
|
495
556
|
|
|
496
557
|
/**
|
|
497
558
|
* Sets the offset of the marker
|
|
498
|
-
* @param
|
|
499
|
-
* @returns
|
|
559
|
+
* @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.
|
|
560
|
+
* @returns `this`
|
|
500
561
|
*/
|
|
501
|
-
setOffset(offset: PointLike) {
|
|
562
|
+
setOffset(offset: PointLike): this {
|
|
502
563
|
this._offset = Point.convert(offset);
|
|
503
564
|
this._update();
|
|
504
565
|
return this;
|
|
505
566
|
}
|
|
506
567
|
|
|
507
|
-
|
|
568
|
+
/**
|
|
569
|
+
* Adds a CSS class to the marker element.
|
|
570
|
+
*
|
|
571
|
+
* @param className - on-empty string with CSS class name to add to marker element
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```
|
|
575
|
+
* let marker = new maplibregl.Marker()
|
|
576
|
+
* marker.addClassName('some-class')
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
addClassName(className: string) {
|
|
580
|
+
this._element.classList.add(className);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Removes a CSS class from the marker element.
|
|
585
|
+
*
|
|
586
|
+
* @param className - Non-empty string with CSS class name to remove from marker element
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* let marker = new maplibregl.Marker()
|
|
591
|
+
* marker.removeClassName('some-class')
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
removeClassName(className: string) {
|
|
595
|
+
this._element.classList.remove(className);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Add or remove the given CSS class on the marker element, depending on whether the element currently has that class.
|
|
600
|
+
*
|
|
601
|
+
* @param className - Non-empty string with CSS class name to add/remove
|
|
602
|
+
*
|
|
603
|
+
* @returns if the class was removed return false, if class was added, then return true
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* let marker = new maplibregl.Marker()
|
|
608
|
+
* marker.toggleClassName('toggleClass')
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
toggleClassName(className: string): boolean {
|
|
612
|
+
return this._element.classList.toggle(className);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
_onMove = (e: MapMouseEvent | MapTouchEvent) => {
|
|
508
616
|
if (!this._isDragging) {
|
|
509
617
|
const clickTolerance = this._clickTolerance || this._map._clickTolerance;
|
|
510
618
|
this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance;
|
|
@@ -522,32 +630,12 @@ export default class Marker extends Evented {
|
|
|
522
630
|
// imply that a drag is about to happen.
|
|
523
631
|
if (this._state === 'pending') {
|
|
524
632
|
this._state = 'active';
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Fired when dragging starts
|
|
528
|
-
*
|
|
529
|
-
* @event dragstart
|
|
530
|
-
* @memberof Marker
|
|
531
|
-
* @instance
|
|
532
|
-
* @type {Object}
|
|
533
|
-
* @property {Marker} marker object that is being dragged
|
|
534
|
-
*/
|
|
535
633
|
this.fire(new Event('dragstart'));
|
|
536
634
|
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Fired while dragging
|
|
540
|
-
*
|
|
541
|
-
* @event drag
|
|
542
|
-
* @memberof Marker
|
|
543
|
-
* @instance
|
|
544
|
-
* @type {Object}
|
|
545
|
-
* @property {Marker} marker object that is being dragged
|
|
546
|
-
*/
|
|
547
635
|
this.fire(new Event('drag'));
|
|
548
|
-
}
|
|
636
|
+
};
|
|
549
637
|
|
|
550
|
-
_onUp() {
|
|
638
|
+
_onUp = () => {
|
|
551
639
|
// revert to normal pointer event handling
|
|
552
640
|
this._element.style.pointerEvents = 'auto';
|
|
553
641
|
this._positionDelta = null;
|
|
@@ -558,22 +646,13 @@ export default class Marker extends Evented {
|
|
|
558
646
|
|
|
559
647
|
// only fire dragend if it was preceded by at least one drag event
|
|
560
648
|
if (this._state === 'active') {
|
|
561
|
-
/**
|
|
562
|
-
* Fired when the marker is finished being dragged
|
|
563
|
-
*
|
|
564
|
-
* @event dragend
|
|
565
|
-
* @memberof Marker
|
|
566
|
-
* @instance
|
|
567
|
-
* @type {Object}
|
|
568
|
-
* @property {Marker} marker object that was dragged
|
|
569
|
-
*/
|
|
570
649
|
this.fire(new Event('dragend'));
|
|
571
650
|
}
|
|
572
651
|
|
|
573
652
|
this._state = 'inactive';
|
|
574
|
-
}
|
|
653
|
+
};
|
|
575
654
|
|
|
576
|
-
_addDragHandler(e: MapMouseEvent | MapTouchEvent) {
|
|
655
|
+
_addDragHandler = (e: MapMouseEvent | MapTouchEvent) => {
|
|
577
656
|
if (this._element.contains(e.originalEvent.target as any)) {
|
|
578
657
|
e.preventDefault();
|
|
579
658
|
|
|
@@ -593,14 +672,14 @@ export default class Marker extends Evented {
|
|
|
593
672
|
this._map.once('mouseup', this._onUp);
|
|
594
673
|
this._map.once('touchend', this._onUp);
|
|
595
674
|
}
|
|
596
|
-
}
|
|
675
|
+
};
|
|
597
676
|
|
|
598
677
|
/**
|
|
599
678
|
* Sets the `draggable` property and functionality of the marker
|
|
600
|
-
* @param
|
|
601
|
-
* @returns
|
|
679
|
+
* @param shouldBeDraggable - Turns drag functionality on/off
|
|
680
|
+
* @returns `this`
|
|
602
681
|
*/
|
|
603
|
-
setDraggable(shouldBeDraggable
|
|
682
|
+
setDraggable(shouldBeDraggable?: boolean): this {
|
|
604
683
|
this._draggable = !!shouldBeDraggable; // convert possible undefined value to false
|
|
605
684
|
|
|
606
685
|
// handle case where map may not exist yet
|
|
@@ -620,18 +699,18 @@ export default class Marker extends Evented {
|
|
|
620
699
|
|
|
621
700
|
/**
|
|
622
701
|
* Returns true if the marker can be dragged
|
|
623
|
-
* @returns
|
|
702
|
+
* @returns True if the marker is draggable.
|
|
624
703
|
*/
|
|
625
|
-
isDraggable() {
|
|
704
|
+
isDraggable(): boolean {
|
|
626
705
|
return this._draggable;
|
|
627
706
|
}
|
|
628
707
|
|
|
629
708
|
/**
|
|
630
709
|
* Sets the `rotation` property of the marker.
|
|
631
|
-
* @param
|
|
632
|
-
* @returns
|
|
710
|
+
* @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting.
|
|
711
|
+
* @returns `this`
|
|
633
712
|
*/
|
|
634
|
-
setRotation(rotation
|
|
713
|
+
setRotation(rotation?: number): this {
|
|
635
714
|
this._rotation = rotation || 0;
|
|
636
715
|
this._update();
|
|
637
716
|
return this;
|
|
@@ -639,18 +718,18 @@ export default class Marker extends Evented {
|
|
|
639
718
|
|
|
640
719
|
/**
|
|
641
720
|
* Returns the current rotation angle of the marker (in degrees).
|
|
642
|
-
* @returns
|
|
721
|
+
* @returns The current rotation angle of the marker.
|
|
643
722
|
*/
|
|
644
|
-
getRotation() {
|
|
723
|
+
getRotation(): number {
|
|
645
724
|
return this._rotation;
|
|
646
725
|
}
|
|
647
726
|
|
|
648
727
|
/**
|
|
649
728
|
* Sets the `rotationAlignment` property of the marker.
|
|
650
|
-
* @param
|
|
651
|
-
* @returns
|
|
729
|
+
* @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto'
|
|
730
|
+
* @returns `this`
|
|
652
731
|
*/
|
|
653
|
-
setRotationAlignment(alignment
|
|
732
|
+
setRotationAlignment(alignment?: Alignment): this {
|
|
654
733
|
this._rotationAlignment = alignment || 'auto';
|
|
655
734
|
this._update();
|
|
656
735
|
return this;
|
|
@@ -658,18 +737,18 @@ export default class Marker extends Evented {
|
|
|
658
737
|
|
|
659
738
|
/**
|
|
660
739
|
* Returns the current `rotationAlignment` property of the marker.
|
|
661
|
-
* @returns
|
|
740
|
+
* @returns The current rotational alignment of the marker.
|
|
662
741
|
*/
|
|
663
|
-
getRotationAlignment() {
|
|
742
|
+
getRotationAlignment(): Alignment {
|
|
664
743
|
return this._rotationAlignment;
|
|
665
744
|
}
|
|
666
745
|
|
|
667
746
|
/**
|
|
668
747
|
* Sets the `pitchAlignment` property of the marker.
|
|
669
|
-
* @param
|
|
670
|
-
* @returns
|
|
748
|
+
* @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.
|
|
749
|
+
* @returns `this`
|
|
671
750
|
*/
|
|
672
|
-
setPitchAlignment(alignment
|
|
751
|
+
setPitchAlignment(alignment?: Alignment): this {
|
|
673
752
|
this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;
|
|
674
753
|
this._update();
|
|
675
754
|
return this;
|
|
@@ -677,9 +756,9 @@ export default class Marker extends Evented {
|
|
|
677
756
|
|
|
678
757
|
/**
|
|
679
758
|
* Returns the current `pitchAlignment` property of the marker.
|
|
680
|
-
* @returns
|
|
759
|
+
* @returns The current pitch alignment of the marker in degrees.
|
|
681
760
|
*/
|
|
682
|
-
getPitchAlignment() {
|
|
761
|
+
getPitchAlignment(): Alignment {
|
|
683
762
|
return this._pitchAlignment;
|
|
684
763
|
}
|
|
685
764
|
}
|
package/src/ui/popup.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {createMap as globalCreateMap, beforeMapTest} from '../util/test/util';
|
|
2
|
-
import Popup,
|
|
3
|
-
import LngLat from '../geo/lng_lat';
|
|
2
|
+
import {Popup, Offset} from './popup';
|
|
3
|
+
import {LngLat} from '../geo/lng_lat';
|
|
4
4
|
import Point from '@mapbox/point-geometry';
|
|
5
5
|
import simulate from '../../test/unit/lib/simulate_interaction';
|
|
6
6
|
import {PositionAnchor} from './anchor';
|