@tomtom-org/maps-sdk 0.38.1 → 0.40.0

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.
@@ -389,7 +389,7 @@ export declare const bboxFromCoordsArray: (coordinates: Position[] | undefined)
389
389
  * // Returns bbox encompassing all three places
390
390
  * ```
391
391
  *
392
- * @group Shared
392
+ * @group Utils
393
393
  */
394
394
  export declare const bboxFromGeoJSON: (hasBBox: HasBBox) => OptionalBBox;
395
395
 
@@ -1665,7 +1665,7 @@ export declare type DistanceDisplayUnits = {
1665
1665
  * const ukSystem: DistanceUnitsType = 'imperial_uk'; // United Kingdom
1666
1666
  * ```
1667
1667
  *
1668
- * @group Shared
1668
+ * @group Utils
1669
1669
  */
1670
1670
  export declare type DistanceUnitsType = 'metric' | 'imperial_us' | 'imperial_uk';
1671
1671
 
@@ -1878,7 +1878,7 @@ export declare interface FeatureCollectionWithProperties<G extends Geometry | nu
1878
1878
  * ```
1879
1879
  * @param meters
1880
1880
  * @param options Options for the display units, including their type and custom ways to display them.
1881
- * @group Shared
1881
+ * @group Utils
1882
1882
  */
1883
1883
  export declare const formatDistance: (meters: number, options?: DistanceDisplayUnits) => string;
1884
1884
 
@@ -1933,7 +1933,7 @@ export declare const formatDistance: (meters: number, options?: DistanceDisplayU
1933
1933
  * // Output: "Estimated time: 2 hr 15 min"
1934
1934
  * ```
1935
1935
  *
1936
- * @group Shared
1936
+ * @group Utils
1937
1937
  */
1938
1938
  export declare const formatDuration: (seconds: number | undefined, options?: TimeDisplayUnits) => string | undefined;
1939
1939
 
@@ -2082,7 +2082,7 @@ export declare type GeometryDataSource = {
2082
2082
  * getPosition(undefined); // Returns: null
2083
2083
  * ```
2084
2084
  *
2085
- * @group Shared
2085
+ * @group Utils
2086
2086
  */
2087
2087
  export declare const getPosition: (hasLngLat: HasLngLat | undefined, options?: GetPositionOptions) => Position | null;
2088
2088
 
@@ -3562,6 +3562,12 @@ export declare type PolygonFeatures<P = GeoJsonProperties> = Omit<FeatureCollect
3562
3562
  bbox?: BBox;
3563
3563
  };
3564
3564
 
3565
+ /**
3566
+ * Creates a GeoJSON Polygon Feature representing the area of the given bounding box.
3567
+ * @param bbox The bounding box defined as [west, south, east, north]
3568
+ */
3569
+ export declare const polygonFromBBox: (bbox: BBox) => Feature<Polygon>;
3570
+
3565
3571
  /**
3566
3572
  * Possible directions a lane can lead to.
3567
3573
  *
@@ -1,6 +1,8 @@
1
1
  import { Anything } from '@tomtom-org/maps-sdk/core';
2
2
  import { BackgroundLayerSpecification } from 'maplibre-gl';
3
3
  import { BBox } from '@tomtom-org/maps-sdk/core';
4
+ import { BBox as BBox_2 } from '@tomtom-org/maps-sdk/core';
5
+ import { BBox as BBox_3 } from '@tomtom-org/maps-sdk/core';
4
6
  import { ChargingSpeed } from '@tomtom-org/maps-sdk/core';
5
7
  import { ChargingStop } from '@tomtom-org/maps-sdk/core';
6
8
  import { CircleLayerSpecification } from 'maplibre-gl';
@@ -33,6 +35,7 @@ import { Places as Places_2 } from '@tomtom-org/maps-sdk/core';
33
35
  import { POICategory } from '@tomtom-org/maps-sdk/core';
34
36
  import { Point } from 'geojson';
35
37
  import { PolygonFeatures } from '@tomtom-org/maps-sdk/core';
38
+ import { Position } from 'geojson';
36
39
  import { Route } from '@tomtom-org/maps-sdk/core';
37
40
  import { RouteProps } from '@tomtom-org/maps-sdk/core';
38
41
  import { Routes } from '@tomtom-org/maps-sdk/core';
@@ -989,6 +992,88 @@ export declare type ByIdOrIndex = {
989
992
  index: number;
990
993
  };
991
994
 
995
+ /**
996
+ * Calculates an expanded bounding box that, when the map is zoomed to it, ensures that the given to-be-contained bounding box
997
+ * is visible within the area not obscured by surrounding UI elements, including optional padding.
998
+ * * In other words, calculates a bounding box that ensure the to-be-contained bbox fits within the visible area of the map.
999
+ *
1000
+ * @remarks
1001
+ * This is useful when you have a specific geographic area (containedBBox) that you want to be fully visible
1002
+ * in the unobscured portion of the map (the area not covered by UI components).
1003
+ * The function returns a larger bounding box that accounts for the space taken by UI elements.
1004
+ *
1005
+ * @param options - The options for calculating expanded bounds
1006
+ * @returns The expanded bounding box as [west, south, east, north], or null if the visible area is too small
1007
+ *
1008
+ * @group Utils
1009
+ */
1010
+ export declare const calculateFittingBBox: (options: CalculateFittingBBoxOptions) => BBox_2 | null;
1011
+
1012
+ /**
1013
+ * Options for calculating expanded bounds.
1014
+ *
1015
+ * @group Utils
1016
+ */
1017
+ export declare type CalculateFittingBBoxOptions = CalculateMapBoundsOptions & {
1018
+ /**
1019
+ * The target bounding box [west, south, east, north] that should be contained in the unobscured area
1020
+ */
1021
+ toBeContainedBBox: BBox_3;
1022
+ };
1023
+
1024
+ /**
1025
+ * Options for calculating map bounds.
1026
+ *
1027
+ * @group Utils
1028
+ */
1029
+ export declare type CalculateMapBoundsOptions = CalculateMapCenterOptions & {
1030
+ /**
1031
+ * Additional padding in pixels to apply around the UI elements or map edges. Default is 0.
1032
+ */
1033
+ paddingPX?: number;
1034
+ };
1035
+
1036
+ /**
1037
+ * Options for calculating map center.
1038
+ *
1039
+ * @group Utils
1040
+ */
1041
+ export declare type CalculateMapCenterOptions = {
1042
+ /** The TomTomMap instance or MapLibre map instance */
1043
+ map: TomTomMap | Map_2;
1044
+ /** Array of HTML elements or DOM selector strings that are positioned over the map */
1045
+ surroundingElements: (HTMLElement | string)[];
1046
+ };
1047
+
1048
+ /**
1049
+ * Calculates the bounding box in lng-lat coordinates of the visible map area
1050
+ * that does not overlap with the given UI HTML elements.
1051
+ *
1052
+ * @remarks
1053
+ * This is useful for determining the area of the map that is not obscured by UI components.
1054
+ *
1055
+ * @param options - The options for calculating map bounds
1056
+ * @returns The padded bounding box as [west, south, east, north], or null if the visible area is too small
1057
+ *
1058
+ * @group Utils
1059
+ */
1060
+ export declare const calculatePaddedBBox: (options: CalculateMapBoundsOptions) => BBox_2 | null;
1061
+
1062
+ /**
1063
+ * Calculates the center point in lng-lat coordinates of the visible map area
1064
+ * that does not overlap with the given UI HTML elements.
1065
+ *
1066
+ * @remarks
1067
+ * * This is useful to offset the map center in a way that it looks harmonious with surrounding UI components.
1068
+ * * It's equivalent to the center of calculatePaddedBBox.
1069
+ *
1070
+ * @param options - The options for calculating map center
1071
+ * @returns The center as [lng, lat], or null if the visible area is too small
1072
+ *
1073
+ * @group Utils
1074
+ */
1075
+ export declare const calculatePaddedCenter: (options: CalculateMapCenterOptions) => Position | null;
1076
+
992
1077
  /**
993
1078
  * Mapping of charging stop speeds to sprite image IDs.
994
1079
  * @group Routing