maplibre-gl 3.2.0 → 3.2.1
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/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 +223 -219
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +200 -144
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +25 -25
- package/src/geo/transform.test.ts +9 -16
- package/src/geo/transform.ts +10 -32
- package/src/render/draw_fill.test.ts +1 -1
- package/src/render/draw_symbol.test.ts +3 -3
- package/src/render/painter.ts +0 -1
- package/src/render/program.ts +0 -1
- package/src/render/terrain.test.ts +17 -0
- package/src/render/terrain.ts +31 -2
- 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/vector_tile_worker_source.test.ts +44 -74
- package/src/source/vector_tile_worker_source.ts +5 -16
- package/src/source/worker_tile.test.ts +143 -0
- package/src/source/worker_tile.ts +26 -7
- package/src/ui/camera.test.ts +12 -9
- package/src/ui/camera.ts +76 -94
- 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 +131 -44
- package/src/ui/map_events.test.ts +76 -0
- package/src/ui/marker.test.ts +1 -1
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
|
+
* @hidden
|
|
267
|
+
* holds the geographical coordinate of the target
|
|
268
|
+
*/
|
|
266
269
|
_elevationCenter: LngLat;
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
/**
|
|
271
|
+
* @hidden
|
|
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
|
+
* @hidden
|
|
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
|
+
* @hidden
|
|
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
|
+
* @hidden
|
|
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 {
|
|
@@ -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,7 +1080,7 @@ 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
|
|
|
@@ -1102,6 +1089,7 @@ export abstract class Camera extends Evented {
|
|
|
1102
1089
|
* If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes.
|
|
1103
1090
|
* This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls.
|
|
1104
1091
|
* It may differ from the state used for rendering (`this.transform`).
|
|
1092
|
+
* @hidden
|
|
1105
1093
|
* @returns Transform to apply changes to
|
|
1106
1094
|
*/
|
|
1107
1095
|
_getTransformForUpdate(): Transform {
|
|
@@ -1115,6 +1103,7 @@ export abstract class Camera extends Evented {
|
|
|
1115
1103
|
|
|
1116
1104
|
/**
|
|
1117
1105
|
* Called after the camera is done being manipulated.
|
|
1106
|
+
* @hidden
|
|
1118
1107
|
* @param tr - the requested camera end state
|
|
1119
1108
|
* Call `transformCameraUpdate` if present, and then apply the "approved" changes.
|
|
1120
1109
|
*/
|
|
@@ -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.
|
|
@@ -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
|
}
|
package/src/ui/map.test.ts
CHANGED
|
@@ -2625,15 +2625,20 @@ describe('Map', () => {
|
|
|
2625
2625
|
});
|
|
2626
2626
|
});
|
|
2627
2627
|
|
|
2628
|
+
describe('cooperativeGestures option', () => {
|
|
2629
|
+
test('cooperativeGesture container element is hidden from a11y tree', () => {
|
|
2630
|
+
const map = createMap({cooperativeGestures: true});
|
|
2631
|
+
|
|
2632
|
+
expect(map.getContainer().querySelector('.maplibregl-cooperative-gesture-screen').getAttribute('aria-hidden')).toBeTruthy();
|
|
2633
|
+
});
|
|
2634
|
+
});
|
|
2635
|
+
|
|
2628
2636
|
describe('getCameraTargetElevation', () => {
|
|
2629
2637
|
test('Elevation is zero without terrain, and matches any given terrain', () => {
|
|
2630
2638
|
const map = createMap();
|
|
2631
2639
|
expect(map.getCameraTargetElevation()).toBe(0);
|
|
2632
2640
|
|
|
2633
|
-
const mockedGetElevation = jest.fn((_tileID: OverscaledTileID, _x: number, _y: number, _extent?: number) => 2000);
|
|
2634
|
-
|
|
2635
2641
|
const terrainStub = {} as Terrain;
|
|
2636
|
-
terrainStub.getElevation = mockedGetElevation;
|
|
2637
2642
|
map.terrain = terrainStub;
|
|
2638
2643
|
|
|
2639
2644
|
const transform = new Transform(0, 22, 0, 60, true);
|
|
@@ -2641,7 +2646,7 @@ describe('Map', () => {
|
|
|
2641
2646
|
transform.center = new LngLat(10.0, 50.0);
|
|
2642
2647
|
transform.zoom = 14;
|
|
2643
2648
|
transform.resize(512, 512);
|
|
2644
|
-
transform.
|
|
2649
|
+
transform.elevation = 2000;
|
|
2645
2650
|
map.transform = transform;
|
|
2646
2651
|
|
|
2647
2652
|
expect(map.getCameraTargetElevation()).toBe(2000);
|
|
@@ -2653,10 +2658,10 @@ describe('Map', () => {
|
|
|
2653
2658
|
test('pitch 90 with terrain', () => {
|
|
2654
2659
|
const map = createMap();
|
|
2655
2660
|
|
|
2656
|
-
const mockedGetElevation = jest.fn((
|
|
2661
|
+
const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200);
|
|
2657
2662
|
|
|
2658
2663
|
const terrainStub = {} as Terrain;
|
|
2659
|
-
terrainStub.
|
|
2664
|
+
terrainStub.getElevationForLngLatZoom = mockedGetElevation;
|
|
2660
2665
|
map.terrain = terrainStub;
|
|
2661
2666
|
|
|
2662
2667
|
// distance between lng x and lng x+1 is 111.2km at same lat
|
|
@@ -2670,10 +2675,10 @@ describe('Map', () => {
|
|
|
2670
2675
|
test('pitch 153.435 with terrain', () => {
|
|
2671
2676
|
const map = createMap();
|
|
2672
2677
|
|
|
2673
|
-
const mockedGetElevation = jest.fn((
|
|
2678
|
+
const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200 * 3);
|
|
2674
2679
|
|
|
2675
2680
|
const terrainStub = {} as Terrain;
|
|
2676
|
-
terrainStub.
|
|
2681
|
+
terrainStub.getElevationForLngLatZoom = mockedGetElevation;
|
|
2677
2682
|
map.terrain = terrainStub;
|
|
2678
2683
|
// distance between lng x and lng x+1 is 111.2km at same lat
|
|
2679
2684
|
// (elevation difference of cam and center) / 2 = grounddistance =>
|
|
@@ -2687,10 +2692,10 @@ describe('Map', () => {
|
|
|
2687
2692
|
test('pitch 63 with terrain', () => {
|
|
2688
2693
|
const map = createMap();
|
|
2689
2694
|
|
|
2690
|
-
const mockedGetElevation = jest.fn((
|
|
2695
|
+
const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200 / 2);
|
|
2691
2696
|
|
|
2692
2697
|
const terrainStub = {} as Terrain;
|
|
2693
|
-
terrainStub.
|
|
2698
|
+
terrainStub.getElevationForLngLatZoom = mockedGetElevation;
|
|
2694
2699
|
map.terrain = terrainStub;
|
|
2695
2700
|
|
|
2696
2701
|
// distance between lng x and lng x+1 is 111.2km at same lat
|
|
@@ -2705,10 +2710,10 @@ describe('Map', () => {
|
|
|
2705
2710
|
test('zoom distance 1000', () => {
|
|
2706
2711
|
const map = createMap();
|
|
2707
2712
|
|
|
2708
|
-
const mockedGetElevation = jest.fn((
|
|
2713
|
+
const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 1000);
|
|
2709
2714
|
|
|
2710
2715
|
const terrainStub = {} as Terrain;
|
|
2711
|
-
terrainStub.
|
|
2716
|
+
terrainStub.getElevationForLngLatZoom = mockedGetElevation;
|
|
2712
2717
|
map.terrain = terrainStub;
|
|
2713
2718
|
|
|
2714
2719
|
const expectedZoom = Math.log2(map.transform.cameraToCenterDistance / mercatorZfromAltitude(1000, 0) / map.transform.tileSize);
|