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,8 +1,24 @@
|
|
|
1
1
|
import Point from '@mapbox/point-geometry';
|
|
2
|
-
import DOM from '../../util/dom';
|
|
3
|
-
import type Map from '../map';
|
|
2
|
+
import {DOM} from '../../util/dom';
|
|
3
|
+
import type {Map} from '../map';
|
|
4
|
+
import {Handler} from '../handler_manager';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* An options object sent to the enable function of some of the handlers
|
|
8
|
+
*/
|
|
9
|
+
export type AroundCenterOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* If "center" is passed, map will zoom around the center of map
|
|
12
|
+
*/
|
|
13
|
+
around: 'center';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers
|
|
18
|
+
*
|
|
19
|
+
* @group Handlers
|
|
20
|
+
*/
|
|
21
|
+
abstract class TwoFingersTouchHandler implements Handler {
|
|
6
22
|
|
|
7
23
|
_enabled: boolean;
|
|
8
24
|
_active: boolean;
|
|
@@ -11,6 +27,9 @@ class TwoFingersTouchHandler {
|
|
|
11
27
|
_startVector: Point;
|
|
12
28
|
_aroundCenter: boolean;
|
|
13
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
14
33
|
constructor() {
|
|
15
34
|
this.reset();
|
|
16
35
|
}
|
|
@@ -20,8 +39,8 @@ class TwoFingersTouchHandler {
|
|
|
20
39
|
delete this._firstTwoTouches;
|
|
21
40
|
}
|
|
22
41
|
|
|
23
|
-
_start(points: [Point, Point])
|
|
24
|
-
_move(points: [Point, Point], pinchAround: Point, e: TouchEvent)
|
|
42
|
+
abstract _start(points: [Point, Point]);
|
|
43
|
+
abstract _move(points: [Point, Point], pinchAround: Point, e: TouchEvent);
|
|
25
44
|
|
|
26
45
|
touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) {
|
|
27
46
|
//log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);
|
|
@@ -69,22 +88,46 @@ class TwoFingersTouchHandler {
|
|
|
69
88
|
this.reset();
|
|
70
89
|
}
|
|
71
90
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Enables the "drag to pitch" interaction.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* map.touchPitch.enable();
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
enable(options?: AroundCenterOptions | boolean | null) {
|
|
75
100
|
this._enabled = true;
|
|
76
|
-
this._aroundCenter = !!options && options.around === 'center';
|
|
101
|
+
this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';
|
|
77
102
|
}
|
|
78
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Disables the "drag to pitch" interaction.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* map.touchPitch.disable();
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
79
112
|
disable() {
|
|
80
113
|
this._enabled = false;
|
|
81
114
|
this.reset();
|
|
82
115
|
}
|
|
83
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Returns a Boolean indicating whether the "drag to pitch" interaction is enabled.
|
|
119
|
+
*
|
|
120
|
+
* @returns `true` if the "drag to pitch" interaction is enabled.
|
|
121
|
+
*/
|
|
84
122
|
isEnabled() {
|
|
85
123
|
return this._enabled;
|
|
86
124
|
}
|
|
87
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used.
|
|
128
|
+
*
|
|
129
|
+
* @returns `true` if the "drag to pitch" interaction is active.
|
|
130
|
+
*/
|
|
88
131
|
isActive() {
|
|
89
132
|
return this._active;
|
|
90
133
|
}
|
|
@@ -104,6 +147,11 @@ function getZoomDelta(distance, lastDistance) {
|
|
|
104
147
|
return Math.log(distance / lastDistance) / Math.LN2;
|
|
105
148
|
}
|
|
106
149
|
|
|
150
|
+
/**
|
|
151
|
+
* The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers
|
|
152
|
+
*
|
|
153
|
+
* @group Handlers
|
|
154
|
+
*/
|
|
107
155
|
export class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {
|
|
108
156
|
|
|
109
157
|
_distance: number;
|
|
@@ -139,6 +187,11 @@ function getBearingDelta(a, b) {
|
|
|
139
187
|
return a.angleWith(b) * 180 / Math.PI;
|
|
140
188
|
}
|
|
141
189
|
|
|
190
|
+
/**
|
|
191
|
+
* The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers
|
|
192
|
+
*
|
|
193
|
+
* @group Handlers
|
|
194
|
+
*/
|
|
142
195
|
export class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {
|
|
143
196
|
_minDiameter: number;
|
|
144
197
|
|
|
@@ -197,6 +250,8 @@ const ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
|
197
250
|
|
|
198
251
|
/**
|
|
199
252
|
* The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.
|
|
253
|
+
*
|
|
254
|
+
* @group Handlers
|
|
200
255
|
*/
|
|
201
256
|
export class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {
|
|
202
257
|
|
|
@@ -281,42 +336,4 @@ export class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {
|
|
|
281
336
|
const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
282
337
|
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
283
338
|
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is enabled.
|
|
287
|
-
*
|
|
288
|
-
* @memberof TwoFingersTouchPitchHandler
|
|
289
|
-
* @name isEnabled
|
|
290
|
-
* @instance
|
|
291
|
-
* @returns {boolean} `true` if the "drag to pitch" interaction is enabled.
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used.
|
|
296
|
-
*
|
|
297
|
-
* @memberof TwoFingersTouchPitchHandler
|
|
298
|
-
* @name isActive
|
|
299
|
-
* @instance
|
|
300
|
-
* @returns {boolean} `true` if the "drag to pitch" interaction is active.
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Enables the "drag to pitch" interaction.
|
|
305
|
-
*
|
|
306
|
-
* @memberof TwoFingersTouchPitchHandler
|
|
307
|
-
* @name enable
|
|
308
|
-
* @instance
|
|
309
|
-
* @example
|
|
310
|
-
* map.touchPitch.enable();
|
|
311
|
-
*/
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Disables the "drag to pitch" interaction.
|
|
315
|
-
*
|
|
316
|
-
* @memberof TwoFingersTouchPitchHandler
|
|
317
|
-
* @name disable
|
|
318
|
-
* @instance
|
|
319
|
-
* @example
|
|
320
|
-
* map.touchPitch.disable();
|
|
321
|
-
*/
|
|
322
339
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import browser from '../util/browser';
|
|
2
|
-
import type Map from './map';
|
|
1
|
+
import {browser} from '../util/browser';
|
|
2
|
+
import type {Map} from './map';
|
|
3
3
|
import {bezier, clamp, extend} from '../util/util';
|
|
4
4
|
import Point from '@mapbox/point-geometry';
|
|
5
5
|
import type {DragPanOptions} from './handler/shim/drag_pan';
|
|
@@ -38,7 +38,7 @@ export type InertiaOptions = {
|
|
|
38
38
|
|
|
39
39
|
export type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;
|
|
40
40
|
|
|
41
|
-
export
|
|
41
|
+
export class HandlerInertia {
|
|
42
42
|
_map: Map;
|
|
43
43
|
_inertiaBuffer: Array<{
|
|
44
44
|
time: number;
|
|
@@ -68,7 +68,7 @@ export default class HandlerInertia {
|
|
|
68
68
|
inertia.shift();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
_onMoveEnd(panInertiaOptions?: DragPanOptions) {
|
|
71
|
+
_onMoveEnd(panInertiaOptions?: DragPanOptions | boolean) {
|
|
72
72
|
this._drainInertiaBuffer();
|
|
73
73
|
if (this._inertiaBuffer.length < 2) {
|
|
74
74
|
return;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {Event} from '../util/evented';
|
|
2
|
-
import DOM from '../util/dom';
|
|
3
|
-
import Map,
|
|
4
|
-
import HandlerInertia from './handler_inertia';
|
|
2
|
+
import {DOM} from '../util/dom';
|
|
3
|
+
import {Map, CompleteMapOptions} from './map';
|
|
4
|
+
import {HandlerInertia} from './handler_inertia';
|
|
5
5
|
import {MapEventHandler, BlockableMapEventHandler} from './handler/map_event';
|
|
6
|
-
import BoxZoomHandler from './handler/box_zoom';
|
|
7
|
-
import TapZoomHandler from './handler/tap_zoom';
|
|
6
|
+
import {BoxZoomHandler} from './handler/box_zoom';
|
|
7
|
+
import {TapZoomHandler} from './handler/tap_zoom';
|
|
8
8
|
import {generateMouseRotationHandler, generateMousePitchHandler, generateMousePanHandler} from './handler/mouse';
|
|
9
|
-
import TouchPanHandler from './handler/touch_pan';
|
|
9
|
+
import {TouchPanHandler} from './handler/touch_pan';
|
|
10
10
|
import {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';
|
|
11
|
-
import KeyboardHandler from './handler/keyboard';
|
|
12
|
-
import ScrollZoomHandler from './handler/scroll_zoom';
|
|
13
|
-
import DoubleClickZoomHandler from './handler/shim/dblclick_zoom';
|
|
14
|
-
import ClickZoomHandler from './handler/click_zoom';
|
|
15
|
-
import TapDragZoomHandler from './handler/tap_drag_zoom';
|
|
16
|
-
import DragPanHandler from './handler/shim/drag_pan';
|
|
17
|
-
import DragRotateHandler from './handler/shim/drag_rotate';
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
11
|
+
import {KeyboardHandler} from './handler/keyboard';
|
|
12
|
+
import {ScrollZoomHandler} from './handler/scroll_zoom';
|
|
13
|
+
import {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';
|
|
14
|
+
import {ClickZoomHandler} from './handler/click_zoom';
|
|
15
|
+
import {TapDragZoomHandler} from './handler/tap_drag_zoom';
|
|
16
|
+
import {DragPanHandler} from './handler/shim/drag_pan';
|
|
17
|
+
import {DragRotateHandler} from './handler/shim/drag_rotate';
|
|
18
|
+
import {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';
|
|
19
|
+
import {extend} from '../util/util';
|
|
20
20
|
import Point from '@mapbox/point-geometry';
|
|
21
21
|
|
|
22
22
|
export type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;
|
|
@@ -28,18 +28,22 @@ class RenderFrameEvent extends Event {
|
|
|
28
28
|
timeStamp: number;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Handlers interpret dom events and return camera changes that should be
|
|
33
|
+
* applied to the map (`HandlerResult`s). The camera changes are all deltas.
|
|
34
|
+
* The handler itself should have no knowledge of the map's current state.
|
|
35
|
+
* This makes it easier to merge multiple results and keeps handlers simpler.
|
|
36
|
+
* For example, if there is a mousedown and mousemove, the mousePan handler
|
|
37
|
+
* would return a `panDelta` on the mousemove.
|
|
38
|
+
*/
|
|
37
39
|
export interface Handler {
|
|
38
40
|
enable(): void;
|
|
39
41
|
disable(): void;
|
|
40
42
|
isEnabled(): boolean;
|
|
41
43
|
isActive(): boolean;
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* `reset` can be called by the manager at any time and must reset everything to it's original state
|
|
46
|
+
*/
|
|
43
47
|
reset(): void;
|
|
44
48
|
// Handlers can optionally implement these methods.
|
|
45
49
|
// They are called with dom events whenever those dom evens are received.
|
|
@@ -52,34 +56,51 @@ export interface Handler {
|
|
|
52
56
|
readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
53
57
|
readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
54
58
|
readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
59
|
+
readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
55
60
|
readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
56
61
|
readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;
|
|
57
62
|
readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;
|
|
58
63
|
readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;
|
|
59
64
|
readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
/**
|
|
66
|
+
* `renderFrame` is the only non-dom event. It is called during render
|
|
67
|
+
* frames and can be used to smooth camera changes (see scroll handler).
|
|
68
|
+
*/
|
|
62
69
|
readonly renderFrame?: () => HandlerResult | void;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
/**
|
|
73
|
+
* All handler methods that are called with events can optionally return a `HandlerResult`.
|
|
74
|
+
*/
|
|
66
75
|
export type HandlerResult = {
|
|
67
76
|
panDelta?: Point;
|
|
68
77
|
zoomDelta?: number;
|
|
69
78
|
bearingDelta?: number;
|
|
70
79
|
pitchDelta?: number;
|
|
71
|
-
|
|
80
|
+
/**
|
|
81
|
+
* the point to not move when changing the camera
|
|
82
|
+
*/
|
|
72
83
|
around?: Point | null;
|
|
73
|
-
|
|
84
|
+
/**
|
|
85
|
+
* same as above, except for pinch actions, which are given higher priority
|
|
86
|
+
*/
|
|
74
87
|
pinchAround?: Point | null;
|
|
75
|
-
|
|
88
|
+
/**
|
|
89
|
+
* A method that can fire a one-off easing by directly changing the map's camera.
|
|
90
|
+
*/
|
|
76
91
|
cameraAnimation?: (map: Map) => any;
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
/**
|
|
93
|
+
* The last three properties are needed by only one handler: scrollzoom.
|
|
94
|
+
* The DOM event to be used as the `originalEvent` on any camera change events.
|
|
95
|
+
*/
|
|
79
96
|
originalEvent?: Event;
|
|
80
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).
|
|
99
|
+
*/
|
|
81
100
|
needsRenderFrame?: boolean;
|
|
82
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The camera changes won't get recorded for inertial zooming.
|
|
103
|
+
*/
|
|
83
104
|
noInertia?: boolean;
|
|
84
105
|
};
|
|
85
106
|
|
|
@@ -99,7 +120,7 @@ function hasChange(result: HandlerResult) {
|
|
|
99
120
|
return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta;
|
|
100
121
|
}
|
|
101
122
|
|
|
102
|
-
class HandlerManager {
|
|
123
|
+
export class HandlerManager {
|
|
103
124
|
_map: Map;
|
|
104
125
|
_el: HTMLElement;
|
|
105
126
|
_handlers: Array<{
|
|
@@ -138,8 +159,6 @@ class HandlerManager {
|
|
|
138
159
|
|
|
139
160
|
this._addDefaultHandlers(options);
|
|
140
161
|
|
|
141
|
-
bindAll(['handleEvent', 'handleWindowEvent'], this);
|
|
142
|
-
|
|
143
162
|
const el = this._el;
|
|
144
163
|
|
|
145
164
|
this._listeners = [
|
|
@@ -199,50 +218,68 @@ class HandlerManager {
|
|
|
199
218
|
|
|
200
219
|
const boxZoom = map.boxZoom = new BoxZoomHandler(map, options);
|
|
201
220
|
this._add('boxZoom', boxZoom);
|
|
221
|
+
if (options.interactive && options.boxZoom) {
|
|
222
|
+
boxZoom.enable();
|
|
223
|
+
}
|
|
202
224
|
|
|
203
225
|
const tapZoom = new TapZoomHandler(map);
|
|
204
226
|
const clickZoom = new ClickZoomHandler(map);
|
|
205
227
|
map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);
|
|
206
228
|
this._add('tapZoom', tapZoom);
|
|
207
229
|
this._add('clickZoom', clickZoom);
|
|
230
|
+
if (options.interactive && options.doubleClickZoom) {
|
|
231
|
+
map.doubleClickZoom.enable();
|
|
232
|
+
}
|
|
208
233
|
|
|
209
234
|
const tapDragZoom = new TapDragZoomHandler();
|
|
210
235
|
this._add('tapDragZoom', tapDragZoom);
|
|
211
236
|
|
|
212
237
|
const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map);
|
|
213
238
|
this._add('touchPitch', touchPitch);
|
|
239
|
+
if (options.interactive && options.touchPitch) {
|
|
240
|
+
map.touchPitch.enable(options.touchPitch);
|
|
241
|
+
}
|
|
214
242
|
|
|
215
243
|
const mouseRotate = generateMouseRotationHandler(options);
|
|
216
244
|
const mousePitch = generateMousePitchHandler(options);
|
|
217
245
|
map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);
|
|
218
246
|
this._add('mouseRotate', mouseRotate, ['mousePitch']);
|
|
219
247
|
this._add('mousePitch', mousePitch, ['mouseRotate']);
|
|
248
|
+
if (options.interactive && options.dragRotate) {
|
|
249
|
+
map.dragRotate.enable();
|
|
250
|
+
}
|
|
220
251
|
|
|
221
252
|
const mousePan = generateMousePanHandler(options);
|
|
222
253
|
const touchPan = new TouchPanHandler(options, map);
|
|
223
254
|
map.dragPan = new DragPanHandler(el, mousePan, touchPan);
|
|
224
255
|
this._add('mousePan', mousePan);
|
|
225
256
|
this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);
|
|
257
|
+
if (options.interactive && options.dragPan) {
|
|
258
|
+
map.dragPan.enable(options.dragPan);
|
|
259
|
+
}
|
|
226
260
|
|
|
227
261
|
const touchRotate = new TwoFingersTouchRotateHandler();
|
|
228
262
|
const touchZoom = new TwoFingersTouchZoomHandler();
|
|
229
|
-
map.touchZoomRotate = new
|
|
263
|
+
map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);
|
|
230
264
|
this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);
|
|
231
265
|
this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);
|
|
266
|
+
if (options.interactive && options.touchZoomRotate) {
|
|
267
|
+
map.touchZoomRotate.enable(options.touchZoomRotate);
|
|
268
|
+
}
|
|
232
269
|
|
|
233
|
-
const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, this);
|
|
270
|
+
const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame());
|
|
234
271
|
this._add('scrollZoom', scrollZoom, ['mousePan']);
|
|
272
|
+
if (options.interactive && options.scrollZoom) {
|
|
273
|
+
map.scrollZoom.enable(options.scrollZoom);
|
|
274
|
+
}
|
|
235
275
|
|
|
236
276
|
const keyboard = map.keyboard = new KeyboardHandler(map);
|
|
237
277
|
this._add('keyboard', keyboard);
|
|
278
|
+
if (options.interactive && options.keyboard) {
|
|
279
|
+
map.keyboard.enable();
|
|
280
|
+
}
|
|
238
281
|
|
|
239
282
|
this._add('blockableMapEvent', new BlockableMapEventHandler(map));
|
|
240
|
-
|
|
241
|
-
for (const name of ['boxZoom', 'doubleClickZoom', 'tapDragZoom', 'touchPitch', 'dragRotate', 'dragPan', 'touchZoomRotate', 'scrollZoom', 'keyboard']) {
|
|
242
|
-
if (options.interactive && options[name]) {
|
|
243
|
-
map[name].enable(options[name]);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
283
|
}
|
|
247
284
|
|
|
248
285
|
_add(handlerName: string, handler: Handler, allowed?: Array<string>) {
|
|
@@ -290,9 +327,9 @@ class HandlerManager {
|
|
|
290
327
|
return false;
|
|
291
328
|
}
|
|
292
329
|
|
|
293
|
-
handleWindowEvent(e:
|
|
330
|
+
handleWindowEvent = (e: { type: 'mousemove' | 'mouseup' | 'touchmove'}) => {
|
|
294
331
|
this.handleEvent(e, `${e.type}Window`);
|
|
295
|
-
}
|
|
332
|
+
};
|
|
296
333
|
|
|
297
334
|
_getMapTouches(touches: TouchList) {
|
|
298
335
|
const mapTouches = [];
|
|
@@ -305,7 +342,7 @@ class HandlerManager {
|
|
|
305
342
|
return mapTouches as any as TouchList;
|
|
306
343
|
}
|
|
307
344
|
|
|
308
|
-
handleEvent(e: Event, eventName?:
|
|
345
|
+
handleEvent = (e: Event, eventName?: keyof Handler) => {
|
|
309
346
|
|
|
310
347
|
if (e.type === 'blur') {
|
|
311
348
|
this.stop(true);
|
|
@@ -337,8 +374,8 @@ class HandlerManager {
|
|
|
337
374
|
handler.reset();
|
|
338
375
|
|
|
339
376
|
} else {
|
|
340
|
-
if (
|
|
341
|
-
data =
|
|
377
|
+
if (handler[eventName || e.type]) {
|
|
378
|
+
data = handler[eventName || e.type](e, points, mapTouches);
|
|
342
379
|
this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);
|
|
343
380
|
if (data && data.needsRenderFrame) {
|
|
344
381
|
this._triggerRenderFrame();
|
|
@@ -377,7 +414,7 @@ class HandlerManager {
|
|
|
377
414
|
this._changes = [];
|
|
378
415
|
cameraAnimation(this._map);
|
|
379
416
|
}
|
|
380
|
-
}
|
|
417
|
+
};
|
|
381
418
|
|
|
382
419
|
mergeHandlerResult(mergedHandlerResult: HandlerResult,
|
|
383
420
|
eventsInProgress: EventsInProgress,
|
|
@@ -581,7 +618,4 @@ class HandlerManager {
|
|
|
581
618
|
this._frameId = this._requestFrame();
|
|
582
619
|
}
|
|
583
620
|
}
|
|
584
|
-
|
|
585
621
|
}
|
|
586
|
-
|
|
587
|
-
export default HandlerManager;
|
package/src/ui/hash.test.ts
CHANGED
package/src/ui/hash.ts
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import throttle from '../util/throttle';
|
|
1
|
+
import {throttle} from '../util/throttle';
|
|
3
2
|
|
|
4
|
-
import type Map from './map';
|
|
3
|
+
import type {Map} from './map';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
/**
|
|
7
6
|
* Adds the map's position to its page's location hash.
|
|
8
7
|
* Passed as an option to the map object.
|
|
9
8
|
*
|
|
10
|
-
* @
|
|
9
|
+
* @group Markers and Controls
|
|
11
10
|
*/
|
|
12
|
-
class Hash {
|
|
11
|
+
export class Hash {
|
|
13
12
|
_map: Map;
|
|
14
|
-
_updateHash: () => ReturnType<typeof setTimeout>;
|
|
15
13
|
_hashName: string;
|
|
16
14
|
|
|
17
15
|
constructor(hashName?: string | null) {
|
|
18
16
|
this._hashName = hashName && encodeURIComponent(hashName);
|
|
19
|
-
bindAll([
|
|
20
|
-
'_getCurrentHash',
|
|
21
|
-
'_onHashChange',
|
|
22
|
-
'_updateHash'
|
|
23
|
-
], this);
|
|
24
|
-
|
|
25
|
-
// Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
|
|
26
|
-
this._updateHash = throttle(this._updateHashUnthrottled.bind(this), 30 * 1000 / 100);
|
|
27
17
|
}
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
/**
|
|
30
20
|
* Map element to listen for coordinate changes
|
|
31
21
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @returns
|
|
22
|
+
* @param map - The map object
|
|
23
|
+
* @returns `this`
|
|
34
24
|
*/
|
|
35
25
|
addTo(map: Map) {
|
|
36
26
|
this._map = map;
|
|
@@ -39,10 +29,10 @@ class Hash {
|
|
|
39
29
|
return this;
|
|
40
30
|
}
|
|
41
31
|
|
|
42
|
-
|
|
32
|
+
/**
|
|
43
33
|
* Removes hash
|
|
44
34
|
*
|
|
45
|
-
* @returns
|
|
35
|
+
* @returns `this`
|
|
46
36
|
*/
|
|
47
37
|
remove() {
|
|
48
38
|
removeEventListener('hashchange', this._onHashChange, false);
|
|
@@ -95,7 +85,7 @@ class Hash {
|
|
|
95
85
|
return `#${hash}`;
|
|
96
86
|
}
|
|
97
87
|
|
|
98
|
-
_getCurrentHash() {
|
|
88
|
+
_getCurrentHash = () => {
|
|
99
89
|
// Get the current hash from location, stripped from its number sign
|
|
100
90
|
const hash = window.location.hash.replace('#', '');
|
|
101
91
|
if (this._hashName) {
|
|
@@ -111,9 +101,9 @@ class Hash {
|
|
|
111
101
|
return (keyval ? keyval[1] || '' : '').split('/');
|
|
112
102
|
}
|
|
113
103
|
return hash.split('/');
|
|
114
|
-
}
|
|
104
|
+
};
|
|
115
105
|
|
|
116
|
-
_onHashChange() {
|
|
106
|
+
_onHashChange = () => {
|
|
117
107
|
const loc = this._getCurrentHash();
|
|
118
108
|
if (loc.length >= 3 && !loc.some(v => isNaN(v))) {
|
|
119
109
|
const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing();
|
|
@@ -126,9 +116,9 @@ class Hash {
|
|
|
126
116
|
return true;
|
|
127
117
|
}
|
|
128
118
|
return false;
|
|
129
|
-
}
|
|
119
|
+
};
|
|
130
120
|
|
|
131
|
-
_updateHashUnthrottled() {
|
|
121
|
+
_updateHashUnthrottled = () => {
|
|
132
122
|
// Replace if already present, else append the updated hash string
|
|
133
123
|
const location = window.location.href.replace(/(#.+)?$/, this.getHashString());
|
|
134
124
|
try {
|
|
@@ -138,8 +128,11 @@ class Hash {
|
|
|
138
128
|
// with iframe.contentWindow.document.write(...).
|
|
139
129
|
// https://github.com/mapbox/mapbox-gl-js/issues/7410
|
|
140
130
|
}
|
|
141
|
-
}
|
|
131
|
+
};
|
|
142
132
|
|
|
143
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
|
|
135
|
+
*/
|
|
136
|
+
_updateHash = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);
|
|
144
137
|
|
|
145
|
-
|
|
138
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import browser from '../../util/browser';
|
|
2
|
-
import Map from '../map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {browser} from '../../util/browser';
|
|
2
|
+
import {Map} from '../map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
5
|
import {beforeMapTest} from '../../util/test/util';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Map from '../../ui/map';
|
|
2
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {Map} from '../../ui/map';
|
|
2
|
+
import {DOM} from '../../util/dom';
|
|
3
3
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
4
|
-
import browser from '../../util/browser';
|
|
4
|
+
import {browser} from '../../util/browser';
|
|
5
5
|
import {beforeMapTest} from '../../util/test/util';
|
|
6
6
|
|
|
7
7
|
let map;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import browser from '../../util/browser';
|
|
2
|
-
import Map from '../../ui/map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {browser} from '../../util/browser';
|
|
2
|
+
import {Map} from '../../ui/map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
5
|
import {beforeMapTest} from '../../util/test/util';
|
|
6
6
|
|