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/src/ui/map.ts CHANGED
@@ -412,7 +412,7 @@ const defaultOptions = {
412
412
  fadeDuration: 300,
413
413
  crossSourceCollisions: true,
414
414
  validateStyle: true,
415
- /** Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */
415
+ /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */
416
416
  maxCanvasSize: [4096, 4096]
417
417
  } as CompleteMapOptions;
418
418
 
@@ -503,7 +503,10 @@ export class Map extends Camera {
503
503
  _maxCanvasSize: [number, number];
504
504
  _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void;
505
505
 
506
- /** image queue throttling handle. To be used later when clean up */
506
+ /**
507
+ * @hidden
508
+ * image queue throttling handle. To be used later when clean up
509
+ */
507
510
  _imageQueueHandle: number;
508
511
 
509
512
  /**
@@ -706,6 +709,7 @@ export class Map extends Camera {
706
709
  /**
707
710
  * Returns a unique number for this map instance which is used for the MapLoadEvent
708
711
  * to make sure we only fire one event per instantiated map object.
712
+ * @hidden
709
713
  * @returns the uniq map ID
710
714
  */
711
715
  _getMapId() {
@@ -715,6 +719,8 @@ export class Map extends Camera {
715
719
  /**
716
720
  * Adds an {@link IControl} to the map, calling `control.onAdd(this)`.
717
721
  *
722
+ * An {@link ErrorEvent} will be fired if the image parameter is invald.
723
+ *
718
724
  * @param control - The {@link IControl} to add.
719
725
  * @param position - position on the map to which the control will be added.
720
726
  * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`.
@@ -753,6 +759,8 @@ export class Map extends Camera {
753
759
  /**
754
760
  * Removes the control from the map.
755
761
  *
762
+ * An {@link ErrorEvent} will be fired if the image parameter is invald.
763
+ *
756
764
  * @param control - The {@link IControl} to remove.
757
765
  * @returns `this`
758
766
  * @example
@@ -791,13 +799,13 @@ export class Map extends Camera {
791
799
  * map.hasControl(navigation);
792
800
  * ```
793
801
  */
794
- hasControl(control: IControl) {
802
+ hasControl(control: IControl): boolean {
795
803
  return this._controls.indexOf(control) > -1;
796
804
  }
797
805
 
798
806
  calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions {
799
807
  if (altitudeTo == null && this.terrain) {
800
- altitudeTo = this.transform.getElevation(to, this.terrain);
808
+ altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom);
801
809
  }
802
810
  return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);
803
811
  }
@@ -810,6 +818,8 @@ export class Map extends Camera {
810
818
  * This method must be called after the map's `container` is resized programmatically
811
819
  * or when the map is shown after being initially hidden with CSS.
812
820
  *
821
+ * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.
822
+ *
813
823
  * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`
814
824
  * events that get triggered as a result of resize. This can be useful for differentiating the
815
825
  * source of an event (for example, user-initiated or programmatically-triggered events).
@@ -857,9 +867,10 @@ export class Map extends Camera {
857
867
  return this;
858
868
  }
859
869
 
860
- /*
870
+ /**
861
871
  * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.
862
872
  * Internally you should use this and not getPixelRatio().
873
+ * @hidden
863
874
  */
864
875
  _getClampedPixelRatio(width: number, height: number): number {
865
876
  const {0: maxCanvasWidth, 1: maxCanvasHeight} = this._maxCanvasSize;
@@ -958,6 +969,8 @@ export class Map extends Camera {
958
969
  * if the map is 512px tall it will not be possible to zoom below zoom 0
959
970
  * no matter what the `minZoom` is set to.
960
971
  *
972
+ * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
973
+ *
961
974
  * @param minZoom - The minimum zoom level to set (-2 - 24).
962
975
  * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).
963
976
  * @returns `this`
@@ -997,6 +1010,8 @@ export class Map extends Camera {
997
1010
  * If the map's current zoom level is higher than the new maximum,
998
1011
  * the map will zoom to the new maximum.
999
1012
  *
1013
+ * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
1014
+ *
1000
1015
  * @param maxZoom - The maximum zoom level to set.
1001
1016
  * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).
1002
1017
  * @returns `this`
@@ -1036,6 +1051,8 @@ export class Map extends Camera {
1036
1051
  * If the map's current pitch is lower than the new minimum,
1037
1052
  * the map will pitch to the new minimum.
1038
1053
  *
1054
+ * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.
1055
+ *
1039
1056
  * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
1040
1057
  * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).
1041
1058
  * @returns `this`
@@ -1071,6 +1088,8 @@ export class Map extends Camera {
1071
1088
  * If the map's current pitch is higher than the new maximum,
1072
1089
  * the map will pitch to the new maximum.
1073
1090
  *
1091
+ * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.
1092
+ *
1074
1093
  * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
1075
1094
  * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).
1076
1095
  * @returns `this`
@@ -1287,6 +1306,7 @@ export class Map extends Camera {
1287
1306
  }
1288
1307
 
1289
1308
  /**
1309
+ * @event
1290
1310
  * Adds a listener for events of a specified type, optionally limited to features in a specified style layer.
1291
1311
  * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description.
1292
1312
  *
@@ -1347,8 +1367,8 @@ export class Map extends Camera {
1347
1367
  * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.
1348
1368
  * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location
1349
1369
  * is within a visible feature in this layer. The event will have a `features` property containing
1350
- * an array of the matching features. If `layerIdOrListener` is not supplied, the event will not have a `features` property.
1351
- * Please note that many event types are not compatible with the optional `layerIdOrListener` parameter.
1370
+ * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property.
1371
+ * Please note that many event types are not compatible with the optional `layer` parameter.
1352
1372
  * @param listener - The function to be called when the event is fired.
1353
1373
  * @returns `this`
1354
1374
  * @example
@@ -1391,20 +1411,27 @@ export class Map extends Camera {
1391
1411
  * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
1392
1412
  * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
1393
1413
  */
1394
- on(type: keyof MapEventType | string, listener: Listener): this;
1395
1414
  on<T extends keyof MapLayerEventType>(
1396
1415
  type: T,
1397
1416
  layer: string,
1398
1417
  listener: (ev: MapLayerEventType[T] & Object) => void,
1399
1418
  ): Map;
1419
+ /**
1420
+ * Overload of the `on` method that allows to listen to events without specifying a layer.
1421
+ * @event
1422
+ * @param type - The type of the event.
1423
+ * @param listener - The listener callback.
1424
+ * @returns `this`
1425
+ */
1400
1426
  on<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
1401
1427
  /**
1402
- * This is an overload of the `on` method that allows to listen to events based on the `layerId`
1428
+ * Overload of the `on` method that allows to listen to events without specifying a layer.
1429
+ * @event
1403
1430
  * @param type - The type of the event.
1404
- * @param layerIdOrListener - The ID of the layer.
1405
1431
  * @param listener - The listener callback.
1406
1432
  * @returns `this`
1407
1433
  */
1434
+ on(type: keyof MapEventType | string, listener: Listener): this;
1408
1435
  on(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {
1409
1436
  if (listener === undefined) {
1410
1437
  return super.on(type, layerIdOrListener as Listener);
@@ -1424,8 +1451,9 @@ export class Map extends Camera {
1424
1451
  }
1425
1452
 
1426
1453
  /**
1427
- * Adds a listener that will be called only once to a specified event type occurring on features in a specified style layer.
1454
+ * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer.
1428
1455
  *
1456
+ * @event
1429
1457
  * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`,
1430
1458
  * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`,
1431
1459
  * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters
@@ -1438,13 +1466,27 @@ export class Map extends Camera {
1438
1466
  * @param listener - The function to be called when the event is fired.
1439
1467
  * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await
1440
1468
  */
1441
- once(type: keyof MapEventType | string, listener?: Listener): this | Promise<any>;
1442
1469
  once<T extends keyof MapLayerEventType>(
1443
1470
  type: T,
1444
1471
  layer: string,
1445
1472
  listener?: (ev: MapLayerEventType[T] & Object) => void,
1446
1473
  ): this | Promise<MapLayerEventType[T] & Object>;
1474
+ /**
1475
+ * Overload of the `once` method that allows to listen to events without specifying a layer.
1476
+ * @event
1477
+ * @param type - The type of the event.
1478
+ * @param listener - The listener callback.
1479
+ * @returns `this`
1480
+ */
1447
1481
  once<T extends keyof MapEventType>(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise<any>;
1482
+ /**
1483
+ * Overload of the `once` method that allows to listen to events without specifying a layer.
1484
+ * @event
1485
+ * @param type - The type of the event.
1486
+ * @param listener - The listener callback.
1487
+ * @returns `this`
1488
+ */
1489
+ once(type: keyof MapEventType | string, listener?: Listener): this | Promise<any>;
1448
1490
  once(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this | Promise<any> {
1449
1491
 
1450
1492
  if (listener === undefined) {
@@ -1461,20 +1503,35 @@ export class Map extends Camera {
1461
1503
  }
1462
1504
 
1463
1505
  /**
1464
- * Removes an event listener for layer-specific events previously added with `Map#on`.
1506
+ * Removes an event listener for events previously added with `Map#on`.
1465
1507
  *
1508
+ * @event
1466
1509
  * @param type - The event type previously used to install the listener.
1467
- * @param layerIdOrListener - The layer ID or listener previously used to install the listener.
1468
- * @param listener - (optional) The function previously installed as a listener.
1510
+ * @param layer - The layer ID or listener previously used to install the listener.
1511
+ * @param listener - The function previously installed as a listener.
1469
1512
  * @returns `this`
1470
1513
  */
1471
- off(type: keyof MapEventType | string, listener: Listener): this;
1472
1514
  off<T extends keyof MapLayerEventType>(
1473
1515
  type: T,
1474
1516
  layer: string,
1475
1517
  listener: (ev: MapLayerEventType[T] & Object) => void,
1476
1518
  ): this;
1519
+ /**
1520
+ * Overload of the `off` method that allows to listen to events without specifying a layer.
1521
+ * @event
1522
+ * @param type - The type of the event.
1523
+ * @param listener - The function previously installed as a listener.
1524
+ * @returns `this`
1525
+ */
1477
1526
  off<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
1527
+ /**
1528
+ * Overload of the `off` method that allows to listen to events without specifying a layer.
1529
+ * @event
1530
+ * @param type - The type of the event.
1531
+ * @param listener - The function previously installed as a listener.
1532
+ * @returns `this`
1533
+ */
1534
+ off(type: keyof MapEventType | string, listener: Listener): this;
1478
1535
  off(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {
1479
1536
  if (listener === undefined) {
1480
1537
  return super.off(type, layerIdOrListener as Listener);
@@ -1830,11 +1887,14 @@ export class Map extends Camera {
1830
1887
  /**
1831
1888
  * Adds a source to the map's style.
1832
1889
  *
1890
+ * Events triggered:
1891
+ *
1892
+ * Triggers the `source.add` event.
1893
+ *
1833
1894
  * @param id - The ID of the source to add. Must not conflict with existing sources.
1834
1895
  * @param source - The source object, conforming to the
1835
- * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/#sources) or
1896
+ * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or
1836
1897
  * {@link CanvasSourceSpecification}.
1837
- * @event `source.add`
1838
1898
  * @returns `this`
1839
1899
  * @example
1840
1900
  * ```ts
@@ -1872,6 +1932,8 @@ export class Map extends Camera {
1872
1932
  * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with
1873
1933
  * the given ID in the map's style has no outstanding network requests, otherwise `false`.
1874
1934
  *
1935
+ * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID.
1936
+ *
1875
1937
  * @param id - The ID of the source to be checked.
1876
1938
  * @returns A Boolean indicating whether the source is loaded.
1877
1939
  * @example
@@ -1890,6 +1952,9 @@ export class Map extends Camera {
1890
1952
 
1891
1953
  /**
1892
1954
  * Loads a 3D terrain mesh, based on a "raster-dem" source.
1955
+ *
1956
+ * Triggers the `terrain` event.
1957
+ *
1893
1958
  * @param options - Options object.
1894
1959
  * @returns `this`
1895
1960
  * @example
@@ -1909,7 +1974,8 @@ export class Map extends Camera {
1909
1974
  this.terrain = null;
1910
1975
  if (this.painter.renderToTexture) this.painter.renderToTexture.destruct();
1911
1976
  this.painter.renderToTexture = null;
1912
- this.transform.updateElevation(this.terrain);
1977
+ this.transform._minEleveationForCurrentTile = 0;
1978
+ this.transform.elevation = 0;
1913
1979
  } else {
1914
1980
  // add terrain
1915
1981
  const sourceCache = this.style.sourceCaches[options.source];
@@ -1923,12 +1989,16 @@ export class Map extends Camera {
1923
1989
  }
1924
1990
  this.terrain = new Terrain(this.painter, sourceCache, options);
1925
1991
  this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain);
1926
- this.transform.updateElevation(this.terrain);
1992
+ this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
1993
+ this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
1927
1994
  this._terrainDataCallback = e => {
1928
1995
  if (e.dataType === 'style') {
1929
1996
  this.terrain.sourceCache.freeRtt();
1930
1997
  } else if (e.dataType === 'source' && e.tile) {
1931
- if (e.sourceId === options.source) this.transform.updateElevation(this.terrain);
1998
+ if (e.sourceId === options.source && !this._elevationFreeze) {
1999
+ this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
2000
+ this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
2001
+ }
1932
2002
  this.terrain.sourceCache.freeRtt(e.tile.tileID);
1933
2003
  }
1934
2004
  };
@@ -2030,11 +2100,12 @@ export class Map extends Camera {
2030
2100
  /**
2031
2101
  * Add an image to the style. This image can be displayed on the map like any other icon in the style's
2032
2102
  * sprite using the image's ID with
2033
- * [`icon-image`](https://maplibre.org/maplibre-style-spec/#layout-symbol-icon-image),
2034
- * [`background-pattern`](https://maplibre.org/maplibre-style-spec/#paint-background-background-pattern),
2035
- * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/#paint-fill-fill-pattern),
2036
- * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/#paint-line-line-pattern).
2037
- * A {@link ErrorEvent} event will be fired if there is not enough space in the sprite to add this image.
2103
+ * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),
2104
+ * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),
2105
+ * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),
2106
+ * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).
2107
+ *
2108
+ * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image.
2038
2109
  *
2039
2110
  * @param id - The ID of the image.
2040
2111
  * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`
@@ -2115,10 +2186,12 @@ export class Map extends Camera {
2115
2186
  /**
2116
2187
  * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's
2117
2188
  * sprite using the image's ID with
2118
- * [`icon-image`](https://maplibre.org/maplibre-style-spec/#layout-symbol-icon-image),
2119
- * [`background-pattern`](https://maplibre.org/maplibre-style-spec/#paint-background-background-pattern),
2120
- * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/#paint-fill-fill-pattern),
2121
- * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/#paint-line-line-pattern).
2189
+ * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),
2190
+ * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),
2191
+ * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),
2192
+ * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).
2193
+ *
2194
+ * An {@link ErrorEvent} will be fired if the image parameter is invald.
2122
2195
  *
2123
2196
  * @param id - The ID of the image.
2124
2197
  * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`
@@ -2188,6 +2261,8 @@ export class Map extends Camera {
2188
2261
  * in the style's original sprite and any images
2189
2262
  * that have been added at runtime using {@link Map#addImage}.
2190
2263
  *
2264
+ * An {@link ErrorEvent} will be fired if the image parameter is invald.
2265
+ *
2191
2266
  * @param id - The ID of the image.
2192
2267
  *
2193
2268
  * @returns A Boolean indicating whether the image exists.
@@ -2263,14 +2338,14 @@ export class Map extends Camera {
2263
2338
  }
2264
2339
 
2265
2340
  /**
2266
- * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/#layers)
2341
+ * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers)
2267
2342
  * to the map's style.
2268
2343
  *
2269
2344
  * A layer defines how data from a specified source will be styled. Read more about layer types
2270
- * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/#layers).
2345
+ * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers).
2271
2346
  *
2272
2347
  * @param layer - The layer to add,
2273
- * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/#layers) or,
2348
+ * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,
2274
2349
  * less commonly, the {@link CustomLayerInterface} specification.
2275
2350
  * The MapLibre Style Specification's layer definition is appropriate for most layers.
2276
2351
  *
@@ -2370,10 +2445,9 @@ export class Map extends Camera {
2370
2445
  /**
2371
2446
  * Removes the layer with the given ID from the map's style.
2372
2447
  *
2373
- * If no such layer exists, an `error` event is fired.
2448
+ * An {@link ErrorEvent} will be fired if the image parameter is invald.
2374
2449
  *
2375
2450
  * @param id - The ID of the layer to remove
2376
- * @event `error`
2377
2451
  * @returns `this`
2378
2452
  *
2379
2453
  * @example
@@ -2407,8 +2481,8 @@ export class Map extends Camera {
2407
2481
 
2408
2482
  /**
2409
2483
  * Sets the zoom extent for the specified style layer. The zoom extent includes the
2410
- * [minimum zoom level](https://maplibre.org/maplibre-style-spec/#layer-minzoom)
2411
- * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/#layer-maxzoom))
2484
+ * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)
2485
+ * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom))
2412
2486
  * at which the layer will be rendered.
2413
2487
  *
2414
2488
  * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the
@@ -2568,12 +2642,11 @@ export class Map extends Camera {
2568
2642
  }
2569
2643
 
2570
2644
  /**
2571
- * Adds a sprite to the map's style.
2645
+ * Adds a sprite to the map's style. Fires the `style` event.
2572
2646
  *
2573
2647
  * @param id - The ID of the sprite to add. Must not conflict with existing sprites.
2574
2648
  * @param url - The URL to load the sprite from
2575
2649
  * @param options - Options object.
2576
- * @event `style`
2577
2650
  * @returns `this`
2578
2651
  * @example
2579
2652
  * ```ts
@@ -2591,10 +2664,9 @@ export class Map extends Camera {
2591
2664
  }
2592
2665
 
2593
2666
  /**
2594
- * Removes the sprite from the map's style.
2667
+ * Removes the sprite from the map's style. Fires the `style` event.
2595
2668
  *
2596
2669
  * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be "default".
2597
- * @event `style`
2598
2670
  * @returns `this`
2599
2671
  * @example
2600
2672
  * ```ts
@@ -2641,7 +2713,7 @@ export class Map extends Camera {
2641
2713
  /**
2642
2714
  * Sets the any combination of light values.
2643
2715
  *
2644
- * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/#light).
2716
+ * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light).
2645
2717
  * @param options - Options object.
2646
2718
  * @returns `this`
2647
2719
  *
@@ -2882,6 +2954,10 @@ export class Map extends Camera {
2882
2954
  <div class="maplibregl-desktop-message">${desktopMessage}</div>
2883
2955
  <div class="maplibregl-mobile-message">${mobileMessage}</div>
2884
2956
  `;
2957
+
2958
+ // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures
2959
+ this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true');
2960
+
2885
2961
  // Add event to canvas container since gesture container is pointer-events: none
2886
2962
  this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false);
2887
2963
 
@@ -2996,6 +3072,7 @@ export class Map extends Camera {
2996
3072
  /**
2997
3073
  * Update this map's style and sources, and re-render the map.
2998
3074
  *
3075
+ * @hidden
2999
3076
  * @param updateStyle - mark the map's style for reprocessing as
3000
3077
  * well as its sources
3001
3078
  * @returns `this`
@@ -3013,6 +3090,7 @@ export class Map extends Camera {
3013
3090
  /**
3014
3091
  * Request that the given callback be executed during the next render
3015
3092
  * frame. Schedule a render frame if one is not already scheduled.
3093
+ * @hidden
3016
3094
  * @returns An id that can be used to cancel the callback
3017
3095
  */
3018
3096
  _requestRenderFrame(callback: () => void): TaskID {
@@ -3032,6 +3110,7 @@ export class Map extends Camera {
3032
3110
  * - A transition is in progress
3033
3111
  *
3034
3112
  * @param paintStartTimeStamp - The time when the animation frame began executing.
3113
+ * @hidden
3035
3114
  *
3036
3115
  * @returns `this`
3037
3116
  */
@@ -3083,8 +3162,16 @@ export class Map extends Camera {
3083
3162
  }
3084
3163
 
3085
3164
  // update terrain stuff
3086
- if (this.terrain) this.terrain.sourceCache.update(this.transform, this.terrain);
3087
- this.transform.updateElevation(this.terrain);
3165
+ if (this.terrain) {
3166
+ this.terrain.sourceCache.update(this.transform, this.terrain);
3167
+ this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
3168
+ if (!this._elevationFreeze) {
3169
+ this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
3170
+ }
3171
+ } else {
3172
+ this.transform._minEleveationForCurrentTile = 0;
3173
+ this.transform.elevation = 0;
3174
+ }
3088
3175
 
3089
3176
  this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions);
3090
3177
 
@@ -4,6 +4,10 @@ import {createMap, beforeMapTest} from '../util/test/util';
4
4
  import {MapGeoJSONFeature} from '../util/vectortile_to_geojson';
5
5
  import {MapLayerEventType, MapLibreEvent} from './events';
6
6
 
7
+ type IsAny<T> = 0 extends T & 1 ? T : never;
8
+ type NotAny<T> = T extends IsAny<T> ? never : T;
9
+ function assertNotAny<T>(_x: NotAny<T>) { }
10
+
7
11
  beforeEach(() => {
8
12
  beforeMapTest();
9
13
  });
@@ -170,6 +174,20 @@ describe('map events', () => {
170
174
  expect(handler.onMove).toHaveBeenCalledTimes(1);
171
175
  });
172
176
 
177
+ test('Map#on allows a listener to infer the event type ', () => {
178
+ const map = createMap();
179
+
180
+ const spy = jest.fn();
181
+ map.on('mousemove', (event) => {
182
+ assertNotAny(event);
183
+ const {lng, lat} = event.lngLat;
184
+ spy({lng, lat});
185
+ });
186
+
187
+ simulate.mousemove(map.getCanvas());
188
+ expect(spy).toHaveBeenCalledTimes(1);
189
+ });
190
+
173
191
  test('Map#off removes a delegated event listener', () => {
174
192
  const map = createMap();
175
193
 
@@ -244,6 +262,64 @@ describe('map events', () => {
244
262
  expect(spyB).not.toHaveBeenCalled();
245
263
  });
246
264
 
265
+ test('Map#off calls an event listener with no type arguments, defaulting to \'unknown\' originalEvent type', () => {
266
+ const map = createMap();
267
+
268
+ const handler = {
269
+ onMove: function onMove(_event: MapLibreEvent) {}
270
+ };
271
+
272
+ jest.spyOn(handler, 'onMove');
273
+
274
+ map.off('move', (event) => handler.onMove(event));
275
+ map.jumpTo({center: {lng: 10, lat: 10}});
276
+
277
+ expect(handler.onMove).toHaveBeenCalledTimes(0);
278
+ });
279
+
280
+ test('Map#off allows a listener to infer the event type ', () => {
281
+ const map = createMap();
282
+
283
+ const spy = jest.fn();
284
+ map.off('mousemove', (event) => {
285
+ assertNotAny(event);
286
+ const {lng, lat} = event.lngLat;
287
+ spy({lng, lat});
288
+ });
289
+
290
+ simulate.mousemove(map.getCanvas());
291
+ expect(spy).toHaveBeenCalledTimes(0);
292
+ });
293
+
294
+ test('Map#once calls an event listener with no type arguments, defaulting to \'unknown\' originalEvent type', () => {
295
+ const map = createMap();
296
+
297
+ const handler = {
298
+ onMoveOnce: function onMoveOnce(_event: MapLibreEvent) {}
299
+ };
300
+
301
+ jest.spyOn(handler, 'onMoveOnce');
302
+
303
+ map.once('move', (event) => handler.onMoveOnce(event));
304
+ map.jumpTo({center: {lng: 10, lat: 10}});
305
+
306
+ expect(handler.onMoveOnce).toHaveBeenCalledTimes(1);
307
+ });
308
+
309
+ test('Map#once allows a listener to infer the event type ', () => {
310
+ const map = createMap();
311
+
312
+ const spy = jest.fn();
313
+ map.once('mousemove', (event) => {
314
+ assertNotAny(event);
315
+ const {lng, lat} = event.lngLat;
316
+ spy({lng, lat});
317
+ });
318
+
319
+ simulate.mousemove(map.getCanvas());
320
+ expect(spy).toHaveBeenCalledTimes(1);
321
+ });
322
+
247
323
  (['mouseenter', 'mouseover'] as (keyof MapLayerEventType)[]).forEach((event) => {
248
324
  test(`Map#on ${event} does not fire if the specified layer does not exist`, () => {
249
325
  const map = createMap();
@@ -800,7 +800,7 @@ describe('marker', () => {
800
800
  .setLngLat([0, 0])
801
801
  .addTo(map);
802
802
  map.terrain = {
803
- getElevation: () => 0
803
+ getElevationForLngLatZoom: () => 0
804
804
  } as any as Terrain;
805
805
 
806
806
  marker.setOffset([10, 10]);