maplibre-gl 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/generate-docs.ts +1 -1
- package/build/generate-struct-arrays.ts +3 -2
- 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 +351 -281
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +254 -181
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +30 -30
- package/src/data/array_types.g.ts +32 -10
- package/src/data/bucket/circle_bucket.ts +1 -0
- package/src/data/bucket/line_bucket.ts +1 -0
- package/src/data/bucket/symbol_bucket.ts +1 -0
- package/src/data/feature_index.ts +1 -0
- package/src/data/program_configuration.ts +1 -0
- package/src/data/segment.ts +2 -0
- package/src/geo/transform.test.ts +9 -16
- package/src/geo/transform.ts +11 -32
- package/src/gl/context.ts +1 -0
- package/src/gl/framebuffer.ts +1 -0
- package/src/gl/index_buffer.ts +1 -0
- package/src/gl/render_pool.ts +2 -1
- package/src/gl/vertex_buffer.ts +1 -0
- package/src/render/draw_fill.test.ts +1 -1
- package/src/render/draw_symbol.test.ts +3 -3
- package/src/render/image_atlas.ts +1 -0
- package/src/render/line_atlas.ts +1 -0
- package/src/render/painter.ts +1 -1
- package/src/render/program.ts +1 -1
- package/src/render/render_to_texture.ts +31 -14
- package/src/render/terrain.test.ts +17 -0
- package/src/render/terrain.ts +34 -2
- package/src/render/texture.ts +1 -0
- package/src/render/uniform_binding.ts +2 -0
- package/src/render/vertex_array_object.ts +1 -0
- package/src/shaders/symbol_sdf.fragment.glsl +9 -3
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
- package/src/source/canvas_source.ts +1 -3
- package/src/source/geojson_source.ts +1 -3
- package/src/source/image_source.ts +2 -4
- package/src/source/raster_dem_tile_source.test.ts +14 -0
- package/src/source/raster_dem_tile_source.ts +0 -11
- package/src/source/raster_tile_source.test.ts +13 -0
- package/src/source/source_cache.ts +1 -0
- package/src/source/source_state.ts +1 -0
- package/src/source/terrain_source_cache.ts +1 -0
- package/src/source/tile.ts +1 -0
- package/src/source/tile_cache.ts +1 -1
- package/src/source/tile_id.ts +1 -0
- package/src/source/vector_tile_worker_source.test.ts +116 -67
- package/src/source/vector_tile_worker_source.ts +30 -16
- package/src/source/worker_source.ts +1 -0
- package/src/source/worker_tile.test.ts +143 -0
- package/src/source/worker_tile.ts +26 -7
- package/src/style/evaluation_parameters.ts +1 -0
- package/src/style/properties.ts +14 -0
- package/src/style/style.ts +1 -0
- package/src/style/style_glyph.ts +1 -0
- package/src/symbol/collision_index.ts +1 -0
- package/src/symbol/grid_index.ts +1 -0
- package/src/ui/camera.test.ts +12 -9
- package/src/ui/camera.ts +77 -95
- package/src/ui/handler/box_zoom.ts +1 -3
- package/src/ui/handler/click_zoom.ts +1 -3
- package/src/ui/handler/keyboard.ts +1 -3
- package/src/ui/handler/scroll_zoom.ts +1 -3
- package/src/ui/handler/shim/dblclick_zoom.ts +1 -3
- package/src/ui/handler/shim/drag_pan.ts +1 -3
- package/src/ui/handler/shim/drag_rotate.ts +1 -3
- package/src/ui/handler/shim/two_fingers_touch.ts +1 -3
- package/src/ui/handler/transform-provider.ts +1 -0
- package/src/ui/handler/two_fingers_touch.ts +1 -3
- package/src/ui/handler_manager.ts +2 -2
- package/src/ui/hash.ts +1 -2
- package/src/ui/map.test.ts +17 -12
- package/src/ui/map.ts +132 -44
- package/src/ui/map_events.test.ts +76 -0
- package/src/ui/marker.test.ts +1 -1
- package/src/util/ajax.test.ts +33 -0
- package/src/util/ajax.ts +5 -0
- package/src/util/image.ts +1 -0
- package/src/util/image_request.ts +2 -2
- package/src/util/performance.ts +1 -2
- package/src/util/struct_array.ts +5 -1
- package/src/util/test/mock_fetch.ts +51 -0
package/src/style/style.ts
CHANGED
package/src/style/style_glyph.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type FeatureKey = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
+
* @internal
|
|
36
37
|
* A collision index used to prevent symbols from overlapping. It keep tracks of
|
|
37
38
|
* where previous symbols have been placed and is used to check if a new
|
|
38
39
|
* symbol overlaps with any previously added symbols.
|
package/src/symbol/grid_index.ts
CHANGED
|
@@ -48,6 +48,7 @@ function overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
+
* @internal
|
|
51
52
|
* GridIndex is a data structure for testing the intersection of
|
|
52
53
|
* circles and rectangles in a 2d plane.
|
|
53
54
|
* It is optimized for rapid insertion and querying.
|
package/src/ui/camera.test.ts
CHANGED
|
@@ -1659,10 +1659,12 @@ describe('#flyTo', () => {
|
|
|
1659
1659
|
|
|
1660
1660
|
test('check elevation callbacks', done => {
|
|
1661
1661
|
const camera = createCamera();
|
|
1662
|
+
camera.terrain = {
|
|
1663
|
+
getElevationForLngLatZoom: () => 100,
|
|
1664
|
+
getMinTileElevationForLngLatZoom: () => 200
|
|
1665
|
+
};
|
|
1662
1666
|
camera.transform = {
|
|
1663
1667
|
elevation: 0,
|
|
1664
|
-
freezeElevation: false,
|
|
1665
|
-
getElevation: () => 100,
|
|
1666
1668
|
recalculateZoom: () => true
|
|
1667
1669
|
};
|
|
1668
1670
|
|
|
@@ -1670,15 +1672,15 @@ describe('#flyTo', () => {
|
|
|
1670
1672
|
// expect(camera._elevationCenter).toBe([10, 0]);
|
|
1671
1673
|
expect(camera._elevationStart).toBe(0);
|
|
1672
1674
|
expect(camera._elevationTarget).toBe(100);
|
|
1673
|
-
expect(camera.
|
|
1675
|
+
expect(camera._elevationFreeze).toBeTruthy();
|
|
1674
1676
|
|
|
1675
|
-
camera.
|
|
1677
|
+
camera.terrain.getElevationForLngLatZoom = () => 200;
|
|
1676
1678
|
camera._updateElevation(0.5);
|
|
1677
1679
|
expect(camera._elevationStart).toBe(-100);
|
|
1678
1680
|
expect(camera._elevationTarget).toBe(200);
|
|
1679
1681
|
|
|
1680
1682
|
camera._finalizeElevation();
|
|
1681
|
-
expect(camera.
|
|
1683
|
+
expect(camera._elevationFreeze).toBeFalsy();
|
|
1682
1684
|
|
|
1683
1685
|
done();
|
|
1684
1686
|
});
|
|
@@ -2015,9 +2017,10 @@ describe('queryTerrainElevation', () => {
|
|
|
2015
2017
|
test('should return the correct elevation', () => {
|
|
2016
2018
|
// Set up mock transform and terrain objects
|
|
2017
2019
|
const transform = new Transform(0, 22, 0, 60, true);
|
|
2018
|
-
transform.getElevation = jest.fn().mockReturnValue(200);
|
|
2019
2020
|
transform.elevation = 50;
|
|
2020
|
-
const terrain = {
|
|
2021
|
+
const terrain = {
|
|
2022
|
+
getElevationForLngLatZoom: jest.fn().mockReturnValue(200)
|
|
2023
|
+
} as any as Terrain;
|
|
2021
2024
|
|
|
2022
2025
|
// Set up camera with mock transform and terrain
|
|
2023
2026
|
camera.transform = transform;
|
|
@@ -2029,12 +2032,12 @@ describe('queryTerrainElevation', () => {
|
|
|
2029
2032
|
const result = camera.queryTerrainElevation(lngLatLike);
|
|
2030
2033
|
|
|
2031
2034
|
// Check that transform.getElevation was called with the correct arguments
|
|
2032
|
-
expect(
|
|
2035
|
+
expect(terrain.getElevationForLngLatZoom).toHaveBeenCalledWith(
|
|
2033
2036
|
expect.objectContaining({
|
|
2034
2037
|
lng: lngLatLike[0],
|
|
2035
2038
|
lat: lngLatLike[1],
|
|
2036
2039
|
}),
|
|
2037
|
-
|
|
2040
|
+
transform.tileZoom
|
|
2038
2041
|
);
|
|
2039
2042
|
|
|
2040
2043
|
// Check that the correct elevation value was returned
|
package/src/ui/camera.ts
CHANGED
|
@@ -262,19 +262,36 @@ export abstract class Camera extends Evented {
|
|
|
262
262
|
_onEaseEnd: (easeId?: string) => void;
|
|
263
263
|
_easeFrameId: TaskID;
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
/**
|
|
266
|
+
* @internal
|
|
267
|
+
* holds the geographical coordinate of the target
|
|
268
|
+
*/
|
|
266
269
|
_elevationCenter: LngLat;
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
/**
|
|
271
|
+
* @internal
|
|
272
|
+
* holds the targ altitude value, = center elevation of the target.
|
|
273
|
+
* This value may changes during flight, because new terrain-tiles loads during flight.
|
|
274
|
+
*/
|
|
269
275
|
_elevationTarget: number;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
/**
|
|
277
|
+
* @internal
|
|
278
|
+
* holds the start altitude value, = center elevation before animation begins
|
|
279
|
+
* this value will recalculated during flight in respect of changing _elevationTarget values,
|
|
280
|
+
* so the linear interpolation between start and target keeps smooth and without jumps.
|
|
281
|
+
*/
|
|
273
282
|
_elevationStart: number;
|
|
274
|
-
|
|
275
|
-
|
|
283
|
+
/**
|
|
284
|
+
* @internal
|
|
285
|
+
* Saves the current state of the elevation freeze - this is used during map movement to prevent "rocky" camera movement.
|
|
286
|
+
*/
|
|
287
|
+
_elevationFreeze: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* @internal
|
|
290
|
+
* Used to track accumulated changes during continuous interaction
|
|
291
|
+
*/
|
|
276
292
|
_requestedCameraState?: Transform;
|
|
277
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* A callback used to defer camera updates or apply arbitrary constraints.
|
|
278
295
|
* If specified, this Camera instance can be used as a stateless component in React etc.
|
|
279
296
|
*/
|
|
280
297
|
transformCameraUpdate: CameraUpdateTransformFunction | null;
|
|
@@ -313,10 +330,10 @@ export abstract class Camera extends Evented {
|
|
|
313
330
|
/**
|
|
314
331
|
* Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`.
|
|
315
332
|
*
|
|
333
|
+
* Triggers the following events: `movestart` and `moveend`.
|
|
334
|
+
*
|
|
316
335
|
* @param center - The centerpoint to set.
|
|
317
336
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
318
|
-
* @event `movestart`
|
|
319
|
-
* @event `moveend`
|
|
320
337
|
* @returns `this`
|
|
321
338
|
* @example
|
|
322
339
|
* ```ts
|
|
@@ -330,11 +347,11 @@ export abstract class Camera extends Evented {
|
|
|
330
347
|
/**
|
|
331
348
|
* Pans the map by the specified offset.
|
|
332
349
|
*
|
|
350
|
+
* Triggers the following events: `movestart` and `moveend`.
|
|
351
|
+
*
|
|
333
352
|
* @param offset - `x` and `y` coordinates by which to pan the map.
|
|
334
353
|
* @param options - Options object
|
|
335
354
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
336
|
-
* @event `movestart`
|
|
337
|
-
* @event `moveend`
|
|
338
355
|
* @returns `this`
|
|
339
356
|
* @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)
|
|
340
357
|
*/
|
|
@@ -346,11 +363,11 @@ export abstract class Camera extends Evented {
|
|
|
346
363
|
/**
|
|
347
364
|
* Pans the map to the specified location with an animated transition.
|
|
348
365
|
*
|
|
366
|
+
* Triggers the following events: `movestart` and `moveend`.
|
|
367
|
+
*
|
|
349
368
|
* @param lnglat - The location to pan the map to.
|
|
350
369
|
* @param options - Options describing the destination and animation of the transition.
|
|
351
370
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
352
|
-
* @event `movestart`
|
|
353
|
-
* @event `moveend`
|
|
354
371
|
* @returns `this`
|
|
355
372
|
* @example
|
|
356
373
|
* ```ts
|
|
@@ -380,14 +397,10 @@ export abstract class Camera extends Evented {
|
|
|
380
397
|
/**
|
|
381
398
|
* Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`.
|
|
382
399
|
*
|
|
400
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.
|
|
401
|
+
*
|
|
383
402
|
* @param zoom - The zoom level to set (0-20).
|
|
384
403
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
385
|
-
* @event `movestart`
|
|
386
|
-
* @event `zoomstart`
|
|
387
|
-
* @event `move`
|
|
388
|
-
* @event `zoom`
|
|
389
|
-
* @event `moveend`
|
|
390
|
-
* @event `zoomend`
|
|
391
404
|
* @returns `this`
|
|
392
405
|
* @example
|
|
393
406
|
* Zoom to the zoom level 5 without an animated transition
|
|
@@ -403,15 +416,11 @@ export abstract class Camera extends Evented {
|
|
|
403
416
|
/**
|
|
404
417
|
* Zooms the map to the specified zoom level, with an animated transition.
|
|
405
418
|
*
|
|
419
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.
|
|
420
|
+
*
|
|
406
421
|
* @param zoom - The zoom level to transition to.
|
|
407
422
|
* @param options - Options object
|
|
408
423
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
409
|
-
* @event `movestart`
|
|
410
|
-
* @event `zoomstart`
|
|
411
|
-
* @event `move`
|
|
412
|
-
* @event `zoom`
|
|
413
|
-
* @event `moveend`
|
|
414
|
-
* @event `zoomend`
|
|
415
424
|
* @returns `this`
|
|
416
425
|
* @example
|
|
417
426
|
* ```ts
|
|
@@ -433,14 +442,10 @@ export abstract class Camera extends Evented {
|
|
|
433
442
|
/**
|
|
434
443
|
* Increases the map's zoom level by 1.
|
|
435
444
|
*
|
|
445
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.
|
|
446
|
+
*
|
|
436
447
|
* @param options - Options object
|
|
437
448
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
438
|
-
* @event `movestart`
|
|
439
|
-
* @event `zoomstart`
|
|
440
|
-
* @event `move`
|
|
441
|
-
* @event `zoom`
|
|
442
|
-
* @event `moveend`
|
|
443
|
-
* @event `zoomend`
|
|
444
449
|
* @returns `this`
|
|
445
450
|
* @example
|
|
446
451
|
* Zoom the map in one level with a custom animation duration
|
|
@@ -456,14 +461,10 @@ export abstract class Camera extends Evented {
|
|
|
456
461
|
/**
|
|
457
462
|
* Decreases the map's zoom level by 1.
|
|
458
463
|
*
|
|
464
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.
|
|
465
|
+
*
|
|
459
466
|
* @param options - Options object
|
|
460
467
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
461
|
-
* @event `movestart`
|
|
462
|
-
* @event `zoomstart`
|
|
463
|
-
* @event `move`
|
|
464
|
-
* @event `zoom`
|
|
465
|
-
* @event `moveend`
|
|
466
|
-
* @event `zoomend`
|
|
467
468
|
* @returns `this`
|
|
468
469
|
* @example
|
|
469
470
|
* Zoom the map out one level with a custom animation offset
|
|
@@ -491,10 +492,10 @@ export abstract class Camera extends Evented {
|
|
|
491
492
|
*
|
|
492
493
|
* Equivalent to `jumpTo({bearing: bearing})`.
|
|
493
494
|
*
|
|
495
|
+
* Triggers the following events: `movestart`, `moveend`, and `rotate`.
|
|
496
|
+
*
|
|
494
497
|
* @param bearing - The desired bearing.
|
|
495
498
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
496
|
-
* @event `movestart`
|
|
497
|
-
* @event `moveend`
|
|
498
499
|
* @returns `this`
|
|
499
500
|
* @example
|
|
500
501
|
* Rotate the map to 90 degrees
|
|
@@ -519,10 +520,10 @@ export abstract class Camera extends Evented {
|
|
|
519
520
|
*
|
|
520
521
|
* Equivalent to `jumpTo({padding: padding})`.
|
|
521
522
|
*
|
|
523
|
+
* Triggers the following events: `movestart` and `moveend`.
|
|
524
|
+
*
|
|
522
525
|
* @param padding - The desired padding.
|
|
523
526
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
524
|
-
* @event `movestart`
|
|
525
|
-
* @event `moveend`
|
|
526
527
|
* @returns `this`
|
|
527
528
|
* @example
|
|
528
529
|
* Sets a left padding of 300px, and a top padding of 50px
|
|
@@ -539,11 +540,11 @@ export abstract class Camera extends Evented {
|
|
|
539
540
|
* Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction
|
|
540
541
|
* that is "up"; for example, a bearing of 90° orients the map so that east is up.
|
|
541
542
|
*
|
|
543
|
+
* Triggers the following events: `movestart`, `moveend`, and `rotate`.
|
|
544
|
+
*
|
|
542
545
|
* @param bearing - The desired bearing.
|
|
543
546
|
* @param options - Options object
|
|
544
547
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
545
|
-
* @event `movestart`
|
|
546
|
-
* @event `moveend`
|
|
547
548
|
* @returns `this`
|
|
548
549
|
*/
|
|
549
550
|
rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this {
|
|
@@ -555,10 +556,10 @@ export abstract class Camera extends Evented {
|
|
|
555
556
|
/**
|
|
556
557
|
* Rotates the map so that north is up (0° bearing), with an animated transition.
|
|
557
558
|
*
|
|
559
|
+
* Triggers the following events: `movestart`, `moveend`, and `rotate`.
|
|
560
|
+
*
|
|
558
561
|
* @param options - Options object
|
|
559
562
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
560
|
-
* @event `movestart`
|
|
561
|
-
* @event `moveend`
|
|
562
563
|
* @returns `this`
|
|
563
564
|
*/
|
|
564
565
|
resetNorth(options?: AnimationOptions, eventData?: any): this {
|
|
@@ -569,10 +570,10 @@ export abstract class Camera extends Evented {
|
|
|
569
570
|
/**
|
|
570
571
|
* Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition.
|
|
571
572
|
*
|
|
573
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`.
|
|
574
|
+
*
|
|
572
575
|
* @param options - Options object
|
|
573
576
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
574
|
-
* @event `movestart`
|
|
575
|
-
* @event `moveend`
|
|
576
577
|
* @returns `this`
|
|
577
578
|
*/
|
|
578
579
|
resetNorthPitch(options?: AnimationOptions, eventData?: any): this {
|
|
@@ -588,10 +589,10 @@ export abstract class Camera extends Evented {
|
|
|
588
589
|
* Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the
|
|
589
590
|
* `bearingSnap` threshold).
|
|
590
591
|
*
|
|
592
|
+
* Triggers the following events: `movestart`, `moveend`, and `rotate`.
|
|
593
|
+
*
|
|
591
594
|
* @param options - Options object
|
|
592
595
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
593
|
-
* @event `movestart`
|
|
594
|
-
* @event `moveend`
|
|
595
596
|
* @returns `this`
|
|
596
597
|
*/
|
|
597
598
|
snapToNorth(options?: AnimationOptions, eventData?: any): this {
|
|
@@ -611,11 +612,10 @@ export abstract class Camera extends Evented {
|
|
|
611
612
|
/**
|
|
612
613
|
* Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`.
|
|
613
614
|
*
|
|
615
|
+
* Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`.
|
|
616
|
+
*
|
|
614
617
|
* @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60).
|
|
615
618
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
616
|
-
* @event `pitchstart`
|
|
617
|
-
* @event `movestart`
|
|
618
|
-
* @event `moveend`
|
|
619
619
|
* @returns `this`
|
|
620
620
|
*/
|
|
621
621
|
setPitch(pitch: number, eventData?: any): this {
|
|
@@ -645,6 +645,7 @@ export abstract class Camera extends Evented {
|
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
/**
|
|
648
|
+
* @internal
|
|
648
649
|
* Calculate the center of these two points in the viewport and use
|
|
649
650
|
* the highest zoom level up to and including `Map#getMaxZoom()` that fits
|
|
650
651
|
* the points in the viewport at the specified bearing.
|
|
@@ -654,7 +655,6 @@ export abstract class Camera extends Evented {
|
|
|
654
655
|
* @param options - the camera options
|
|
655
656
|
* @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.
|
|
656
657
|
* If map is unable to fit, method will warn and return undefined.
|
|
657
|
-
* @hidden
|
|
658
658
|
* @example
|
|
659
659
|
* ```ts
|
|
660
660
|
* let p0 = [-79, 43];
|
|
@@ -738,12 +738,12 @@ export abstract class Camera extends Evented {
|
|
|
738
738
|
* Pans and zooms the map to contain its visible area within the specified geographical bounds.
|
|
739
739
|
* This function will also reset the map's bearing to 0 if bearing is nonzero.
|
|
740
740
|
*
|
|
741
|
+
* Triggers the following events: `movestart` and `moveend`.
|
|
742
|
+
*
|
|
741
743
|
* @param bounds - Center these bounds in the viewport and use the highest
|
|
742
744
|
* zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport.
|
|
743
745
|
* @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below.
|
|
744
746
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
745
|
-
* @event `movestart`
|
|
746
|
-
* @event `moveend`
|
|
747
747
|
* @returns `this`
|
|
748
748
|
* @example
|
|
749
749
|
* ```ts
|
|
@@ -766,13 +766,13 @@ export abstract class Camera extends Evented {
|
|
|
766
766
|
* once the map is rotated to the specified bearing. To zoom without rotating,
|
|
767
767
|
* pass in the current map bearing.
|
|
768
768
|
*
|
|
769
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`.
|
|
770
|
+
*
|
|
769
771
|
* @param p0 - First point on screen, in pixel coordinates
|
|
770
772
|
* @param p1 - Second point on screen, in pixel coordinates
|
|
771
773
|
* @param bearing - Desired map bearing at end of animation, in degrees
|
|
772
774
|
* @param options - Options object
|
|
773
775
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
774
|
-
* @event `movestart`
|
|
775
|
-
* @event `moveend`
|
|
776
776
|
* @returns `this`
|
|
777
777
|
* @example
|
|
778
778
|
* ```ts
|
|
@@ -813,18 +813,11 @@ export abstract class Camera extends Evented {
|
|
|
813
813
|
* an animated transition. The map will retain its current values for any
|
|
814
814
|
* details not specified in `options`.
|
|
815
815
|
*
|
|
816
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,
|
|
817
|
+
* `pitch`, `pitchend`, and `rotate`.
|
|
818
|
+
*
|
|
816
819
|
* @param options - Options object
|
|
817
820
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
818
|
-
* @event `movestart`
|
|
819
|
-
* @event `zoomstart`
|
|
820
|
-
* @event `pitchstart`
|
|
821
|
-
* @event `rotate`
|
|
822
|
-
* @event `move`
|
|
823
|
-
* @event `zoom`
|
|
824
|
-
* @event `pitch`
|
|
825
|
-
* @event `moveend`
|
|
826
|
-
* @event `zoomend`
|
|
827
|
-
* @event `pitchend`
|
|
828
821
|
* @returns `this`
|
|
829
822
|
* @example
|
|
830
823
|
* ```ts
|
|
@@ -940,19 +933,12 @@ export abstract class Camera extends Evented {
|
|
|
940
933
|
* the `reduced motion` accessibility feature enabled in their operating system,
|
|
941
934
|
* unless `options` includes `essential: true`.
|
|
942
935
|
*
|
|
936
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,
|
|
937
|
+
* `pitch`, `pitchend`, and `rotate`.
|
|
938
|
+
*
|
|
943
939
|
* @param options - Options describing the destination and animation of the transition.
|
|
944
940
|
* Accepts {@link CameraOptions} and {@link AnimationOptions}.
|
|
945
941
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
946
|
-
* @event `movestart`
|
|
947
|
-
* @event `zoomstart`
|
|
948
|
-
* @event `pitchstart`
|
|
949
|
-
* @event `rotate`
|
|
950
|
-
* @event `move`
|
|
951
|
-
* @event `zoom`
|
|
952
|
-
* @event `pitch`
|
|
953
|
-
* @event `moveend`
|
|
954
|
-
* @event `zoomend`
|
|
955
|
-
* @event `pitchend`
|
|
956
942
|
* @returns `this`
|
|
957
943
|
* @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)
|
|
958
944
|
*/
|
|
@@ -1076,12 +1062,13 @@ export abstract class Camera extends Evented {
|
|
|
1076
1062
|
_prepareElevation(center: LngLat) {
|
|
1077
1063
|
this._elevationCenter = center;
|
|
1078
1064
|
this._elevationStart = this.transform.elevation;
|
|
1079
|
-
this._elevationTarget = this.
|
|
1080
|
-
this.
|
|
1065
|
+
this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom);
|
|
1066
|
+
this._elevationFreeze = true;
|
|
1081
1067
|
}
|
|
1082
1068
|
|
|
1083
1069
|
_updateElevation(k: number) {
|
|
1084
|
-
|
|
1070
|
+
this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);
|
|
1071
|
+
const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);
|
|
1085
1072
|
// target terrain updated during flight, slowly move camera to new height
|
|
1086
1073
|
if (k < 1 && elevation !== this._elevationTarget) {
|
|
1087
1074
|
const pitch1 = this._elevationTarget - this._elevationStart;
|
|
@@ -1093,11 +1080,12 @@ export abstract class Camera extends Evented {
|
|
|
1093
1080
|
}
|
|
1094
1081
|
|
|
1095
1082
|
_finalizeElevation() {
|
|
1096
|
-
this.
|
|
1083
|
+
this._elevationFreeze = false;
|
|
1097
1084
|
this.transform.recalculateZoom(this.terrain);
|
|
1098
1085
|
}
|
|
1099
1086
|
|
|
1100
1087
|
/**
|
|
1088
|
+
* @internal
|
|
1101
1089
|
* Called when the camera is about to be manipulated.
|
|
1102
1090
|
* If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes.
|
|
1103
1091
|
* This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls.
|
|
@@ -1114,6 +1102,7 @@ export abstract class Camera extends Evented {
|
|
|
1114
1102
|
}
|
|
1115
1103
|
|
|
1116
1104
|
/**
|
|
1105
|
+
* @internal
|
|
1117
1106
|
* Called after the camera is done being manipulated.
|
|
1118
1107
|
* @param tr - the requested camera end state
|
|
1119
1108
|
* Call `transformCameraUpdate` if present, and then apply the "approved" changes.
|
|
@@ -1188,20 +1177,13 @@ export abstract class Camera extends Evented {
|
|
|
1188
1177
|
* if the user has the `reduced motion` accessibility feature enabled in their operating system,
|
|
1189
1178
|
* unless 'options' includes `essential: true`.
|
|
1190
1179
|
*
|
|
1180
|
+
* Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,
|
|
1181
|
+
* `pitch`, `pitchend`, and `rotate`.
|
|
1182
|
+
*
|
|
1191
1183
|
* @param options - Options describing the destination and animation of the transition.
|
|
1192
1184
|
* Accepts {@link CameraOptions}, {@link AnimationOptions},
|
|
1193
1185
|
* and the following additional options.
|
|
1194
1186
|
* @param eventData - Additional properties to be added to event objects of events triggered by this method.
|
|
1195
|
-
* @event `movestart`
|
|
1196
|
-
* @event `zoomstart`
|
|
1197
|
-
* @event `pitchstart`
|
|
1198
|
-
* @event `move`
|
|
1199
|
-
* @event `zoom`
|
|
1200
|
-
* @event `rotate`
|
|
1201
|
-
* @event `pitch`
|
|
1202
|
-
* @event `moveend`
|
|
1203
|
-
* @event `zoomend`
|
|
1204
|
-
* @event `pitchend`
|
|
1205
1187
|
* @returns `this`
|
|
1206
1188
|
* @example
|
|
1207
1189
|
* ```ts
|
|
@@ -1482,9 +1464,9 @@ export abstract class Camera extends Evented {
|
|
|
1482
1464
|
if (!this.terrain) {
|
|
1483
1465
|
return null;
|
|
1484
1466
|
}
|
|
1485
|
-
const elevation = this.
|
|
1467
|
+
const elevation = this.terrain.getElevationForLngLatZoom(LngLat.convert(lngLatLike), this.transform.tileZoom);
|
|
1486
1468
|
/**
|
|
1487
|
-
* Different zoomlevels with different terrain-tiles the
|
|
1469
|
+
* Different zoomlevels with different terrain-tiles the elevation-values are not the same.
|
|
1488
1470
|
* map.transform.elevation variable with the center-altitude.
|
|
1489
1471
|
* In maplibre the proj-matrix is translated by this value in negative z-direction.
|
|
1490
1472
|
* So we need to add this value to the elevation to get the correct value.
|
|
@@ -33,9 +33,7 @@ export class KeyboardHandler implements Handler {
|
|
|
33
33
|
_pitchStep: number;
|
|
34
34
|
_rotationDisabled: boolean;
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
36
|
+
/** @internal */
|
|
39
37
|
constructor(map: Map) {
|
|
40
38
|
this._tr = new TransformProvider(map);
|
|
41
39
|
const stepOptions = defaultOptions;
|
|
@@ -62,9 +62,7 @@ export class ScrollZoomHandler implements Handler {
|
|
|
62
62
|
_defaultZoomRate: number;
|
|
63
63
|
_wheelZoomRate: number;
|
|
64
64
|
|
|
65
|
-
/**
|
|
66
|
-
* @hidden
|
|
67
|
-
*/
|
|
65
|
+
/** @internal */
|
|
68
66
|
constructor(map: Map, triggerRenderFrame: () => void) {
|
|
69
67
|
this._map = map;
|
|
70
68
|
this._tr = new TransformProvider(map);
|
|
@@ -12,9 +12,7 @@ export class DoubleClickZoomHandler {
|
|
|
12
12
|
_clickZoom: ClickZoomHandler;
|
|
13
13
|
_tapZoom: TapZoomHandler;
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
15
|
+
/** @internal */
|
|
18
16
|
constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) {
|
|
19
17
|
this._clickZoom = clickZoom;
|
|
20
18
|
this._tapZoom = TapZoom;
|
|
@@ -41,9 +41,7 @@ export class DragPanHandler {
|
|
|
41
41
|
_touchPan: TouchPanHandler;
|
|
42
42
|
_inertiaOptions: DragPanOptions | boolean;
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* @hidden
|
|
46
|
-
*/
|
|
44
|
+
/** @internal */
|
|
47
45
|
constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler) {
|
|
48
46
|
this._el = el;
|
|
49
47
|
this._mousePan = mousePan;
|
|
@@ -20,9 +20,7 @@ export class DragRotateHandler {
|
|
|
20
20
|
_mousePitch: MousePitchHandler;
|
|
21
21
|
_pitchWithRotate: boolean;
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
23
|
+
/** @internal */
|
|
26
24
|
constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler) {
|
|
27
25
|
this._pitchWithRotate = options.pitchWithRotate;
|
|
28
26
|
this._mouseRotate = mouseRotate;
|
|
@@ -19,9 +19,7 @@ export class TwoFingersTouchZoomRotateHandler {
|
|
|
19
19
|
_rotationDisabled: boolean;
|
|
20
20
|
_enabled: boolean;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* @hidden
|
|
24
|
-
*/
|
|
22
|
+
/** @internal */
|
|
25
23
|
constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler) {
|
|
26
24
|
this._el = el;
|
|
27
25
|
this._touchZoom = touchZoom;
|
|
@@ -5,6 +5,7 @@ import Point from '@mapbox/point-geometry';
|
|
|
5
5
|
import {LngLat} from '../../geo/lng_lat';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* @internal
|
|
8
9
|
* Shared utilities for the Handler classes to access the correct camera state.
|
|
9
10
|
* If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering.
|
|
10
11
|
* The handlers need the "desired state" to track accumulated changes.
|
|
@@ -504,10 +504,10 @@ export class HandlerManager {
|
|
|
504
504
|
(combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) {
|
|
505
505
|
// When starting to drag or move, flag it and register moveend to clear flagging
|
|
506
506
|
this._terrainMovement = true;
|
|
507
|
-
|
|
507
|
+
this._map._elevationFreeze = true;
|
|
508
508
|
tr.setLocationAtPoint(loc, around);
|
|
509
509
|
this._map.once('moveend', () => {
|
|
510
|
-
|
|
510
|
+
this._map._elevationFreeze = false;
|
|
511
511
|
this._terrainMovement = false;
|
|
512
512
|
tr.recalculateZoom(map.terrain);
|
|
513
513
|
});
|
package/src/ui/hash.ts
CHANGED
|
@@ -133,6 +133,5 @@ export class Hash {
|
|
|
133
133
|
/**
|
|
134
134
|
* Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
|
|
135
135
|
*/
|
|
136
|
-
_updateHash = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);
|
|
137
|
-
|
|
136
|
+
_updateHash: () => ReturnType<typeof setTimeout> = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);
|
|
138
137
|
}
|