@tomtom-org/maps-sdk 0.54.0 → 0.55.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/map/package.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "build:watch": "vite build --watch",
18
18
  "build:full": "pnpm type-check && pnpm build",
19
19
  "type-check": "tsc --noEmit",
20
+ "refresh-style-fixture": "node scripts/refresh-style-fixture.mjs",
20
21
  "clean:dist": "rimraf ./dist"
21
22
  },
22
23
  "devDependencies": {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tomtom-org/maps-sdk",
3
3
  "author": "TomTom International B.V.",
4
4
  "license": "See in LICENSE.txt",
5
- "version": "0.54.0",
5
+ "version": "0.55.1",
6
6
  "description": "TomTom maps, search, geocoding, routing, isochrones, EV and traffic for JavaScript — typed GeoJSON services and a MapLibre GL JS map.",
7
7
  "homepage": "https://docs.tomtom.com/maps-sdk-js/introduction/overview",
8
8
  "repository": {
@@ -425,6 +425,66 @@ export declare const buildResponseError: (error: unknown, serviceName: ServiceNa
425
425
  */
426
426
  export declare const buildValidationError: (error: ValidationError, serviceName: ServiceName) => SDKError;
427
427
  //#endregion
428
+ //#region src/shared/types/geoBias.d.ts
429
+ /**
430
+ * A point to search around, optionally bounded by a radius.
431
+ *
432
+ * @remarks
433
+ * Without `radiusMeters` the point biases the ranking without restricting results; with it, results
434
+ * are confined to that circle.
435
+ *
436
+ * @group Search
437
+ */
438
+ export type PointGeoBias = {
439
+ /**
440
+ * The point to search around, as `[longitude, latitude]` or any GeoJSON form carrying one.
441
+ */
442
+ position: HasLngLat;
443
+ /**
444
+ * Radius around `position`, in metres. Values of zero or less are ignored by the API.
445
+ */
446
+ radiusMeters?: number;
447
+ };
448
+ /**
449
+ * A rectangle to confine results to.
450
+ *
451
+ * @group Search
452
+ */
453
+ export type BoundingBoxGeoBias = {
454
+ /**
455
+ * The rectangle, as `[minLongitude, minLatitude, maxLongitude, maxLatitude]` or any GeoJSON
456
+ * value a bounding box can be derived from — a `bbox` property, a Feature, or a geometry.
457
+ */
458
+ boundingBox: HasBBox;
459
+ };
460
+ /**
461
+ * Where to look: a point with an optional radius, or a bounding box — one or the other.
462
+ *
463
+ * @remarks
464
+ * The two cannot be combined, which is why they are a union rather than separate options: an
465
+ * endpoint applies exactly one geographic bias per request.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * // Around a point, ranking bias only
470
+ * const nearAmsterdam: GeoBias = { position: [4.9, 52.3] };
471
+ *
472
+ * // Around a point, confined to 2 km
473
+ * const within2km: GeoBias = { position: [4.9, 52.3], radiusMeters: 2000 };
474
+ *
475
+ * // Inside the visible map area
476
+ * const inViewport: GeoBias = { boundingBox: map.getBounds().toArray().flat() as BBox };
477
+ * ```
478
+ *
479
+ * @group Search
480
+ */
481
+ export type GeoBias = (PointGeoBias & {
482
+ boundingBox?: never;
483
+ }) | (BoundingBoxGeoBias & {
484
+ position?: never;
485
+ radiusMeters?: never;
486
+ });
487
+ //#endregion
428
488
  //#region src/shared/types/commonGeocodeAndFuzzySearchParams.d.ts
429
489
  /**
430
490
  * Common parameters shared between fuzzy search and geocoding services.
@@ -501,86 +561,19 @@ export type CommonGeocodeAndFuzzySearchParams = {
501
561
  */
502
562
  offset?: number;
503
563
  /**
504
- * Search radius in meters around the specified position.
505
- *
506
- * When used with `position`, constrains results to locations within
507
- * this distance from the position. Creates a circular search area.
564
+ * Where to look: a point with an optional radius, or a bounding box.
508
565
  *
509
566
  * @remarks
510
- * **Behavior:**
511
- * - Must be used with `position` parameter
512
- * - Values ≤ 0 are ignored (parameter has no effect)
513
- * - Mutually exclusive with `boundingBox` (radius takes precedence)
514
- *
515
- * **Typical Values:**
516
- * - 500m: Immediate vicinity (walking distance)
517
- * - 2000m: Neighborhood area
518
- * - 5000m: City district
519
- * - 10000m: Greater city area
567
+ * A point without `radiusMeters` biases the ranking; with one, or with a `boundingBox`, results
568
+ * are confined to that area. Leave it out to search without a geographic bias.
520
569
  *
521
570
  * @example
522
571
  * ```typescript
523
- * // Search within 1km radius
524
- * radiusMeters: 1000
525
- *
526
- * // Search within 5km radius
527
- * radiusMeters: 5000
528
- *
529
- * // Combined with position
530
- * position: [4.9, 52.3],
531
- * radiusMeters: 2000 // Within 2km of Amsterdam center
572
+ * geoBias: { position: [4.9, 52.3], radiusMeters: 2000 }
573
+ * geoBias: { boundingBox: [4.8, 52.3, 5.0, 52.4] }
532
574
  * ```
533
575
  */
534
- radiusMeters?: number;
535
- /**
536
- * Bounding box to constrain search results to a rectangular area.
537
- *
538
- * Filters results to only include locations within the specified bounding box.
539
- * Accepts various GeoJSON formats that contain or can derive a bounding box.
540
- *
541
- * @remarks
542
- * **Accepted Formats:**
543
- * - Direct BBox array: `[minLng, minLat, maxLng, maxLat]`
544
- * - GeoJSON Feature/FeatureCollection with bbox property
545
- * - Any GeoJSON geometry (bbox calculated automatically)
546
- *
547
- * **Important:**
548
- * - Mutually exclusive with Point-Radius parameters
549
- * - Point-Radius (`position` + `radiusMeters`) takes precedence if both provided
550
- * - Useful for map viewport filtering
551
- *
552
- * **Use Cases:**
553
- * - "Search in visible map area"
554
- * - City/region boundary filtering
555
- * - Custom geographic restrictions
556
- *
557
- * @example
558
- * ```typescript
559
- * // Direct bounding box (Amsterdam area)
560
- * boundingBox: [4.8, 52.3, 5.0, 52.4]
561
- *
562
- * // From GeoJSON Feature
563
- * boundingBox: {
564
- * type: 'Feature',
565
- * bbox: [4.8, 52.3, 5.0, 52.4],
566
- * geometry: { ... },
567
- * properties: {}
568
- * }
569
- *
570
- * // From Polygon (bbox calculated)
571
- * boundingBox: {
572
- * type: 'Polygon',
573
- * coordinates: [[
574
- * [4.8, 52.3],
575
- * [5.0, 52.3],
576
- * [5.0, 52.4],
577
- * [4.8, 52.4],
578
- * [4.8, 52.3]
579
- * ]]
580
- * }
581
- * ```
582
- */
583
- boundingBox?: HasBBox;
576
+ geoBias?: GeoBias;
584
577
  /**
585
578
  * Restrict search to specific countries.
586
579
  *
@@ -4028,28 +4021,19 @@ type AutocompleteSearchParams = CommonServiceParams<URL, AutocompleteSearchRespo
4028
4021
  */
4029
4022
  query: string;
4030
4023
  /**
4031
- * Position to bias results towards.
4032
- *
4033
- * Results closer to this location will be ranked higher in suggestions.
4024
+ * The point to bias suggestions towards, and how far around it to look.
4034
4025
  *
4035
4026
  * @remarks
4036
- * Can be provided as:
4037
- * - Object with `lon` and `lat` properties
4038
- * - Array `[longitude, latitude]`
4039
- *
4040
- * When used without `radiusMeters`, biases results but doesn't restrict them.
4041
- * When used with `radiusMeters`, constrains results to that area.
4027
+ * This endpoint biases by point only — it takes no bounding box. Without `radiusMeters` the
4028
+ * point ranks nearer suggestions higher without restricting them.
4042
4029
  *
4043
4030
  * @example
4044
4031
  * ```typescript
4045
- * // Object format
4046
- * position: { lon: 4.9041, lat: 52.3676 }
4047
- *
4048
- * // Array format
4049
- * position: [4.9041, 52.3676]
4032
+ * geoBias: { position: [4.9041, 52.3676] }
4033
+ * geoBias: { position: [4.9041, 52.3676], radiusMeters: 5000 }
4050
4034
  * ```
4051
4035
  */
4052
- position?: HasLngLat;
4036
+ geoBias?: PointGeoBias;
4053
4037
  /**
4054
4038
  * Maximum number of suggestions to return.
4055
4039
  *
@@ -4063,24 +4047,6 @@ type AutocompleteSearchParams = CommonServiceParams<URL, AutocompleteSearchRespo
4063
4047
  * ```
4064
4048
  */
4065
4049
  limit?: number;
4066
- /**
4067
- * Search radius in meters from the position.
4068
- *
4069
- * When combined with `position`, restricts results to within this radius.
4070
- * Without `position`, this parameter is ignored.
4071
- *
4072
- * @remarks
4073
- * Only results within this distance from `position` will be returned.
4074
- * Values ≤ 0 are ignored.
4075
- *
4076
- * @example
4077
- * ```typescript
4078
- * // Search within 5km of position
4079
- * position: [4.9, 52.3],
4080
- * radiusMeters: 5000
4081
- * ```
4082
- */
4083
- radiusMeters?: number;
4084
4050
  /**
4085
4051
  * Restrict results to specific countries.
4086
4052
  *
@@ -4490,31 +4456,6 @@ type GeocodingParams = Omit<CommonPlacesParams<URL, GeocodingResponseAPI> & Comm
4490
4456
  * ```
4491
4457
  */
4492
4458
  query: string;
4493
- /**
4494
- * Geographic position to bias geocoding results toward.
4495
- *
4496
- * When provided, results closer to this position are ranked higher.
4497
- * Useful for resolving ambiguous queries (e.g. "Main Street") to
4498
- * the right city or region.
4499
- *
4500
- * Accepts any {@link HasLngLat}-compatible value:
4501
- * - `[longitude, latitude]` coordinate pair
4502
- * - GeoJSON `Point` geometry
4503
- * - GeoJSON `Feature<Point>` — pass a {@link Place} directly
4504
- *
4505
- * @example
4506
- * ```typescript
4507
- * // Coordinate pair
4508
- * position: [4.9041, 52.3676]
4509
- *
4510
- * // Place result from a previous search (e.g. user's selected location)
4511
- * position: selectedPlace
4512
- *
4513
- * // GeoJSON Point
4514
- * position: { type: 'Point', coordinates: [4.9041, 52.3676] }
4515
- * ```
4516
- */
4517
- position?: HasLngLat;
4518
4459
  /**
4519
4460
  * Indexes for which extended postal codes should be included in the results.
4520
4461
  *
@@ -7976,8 +7917,8 @@ type ExplorationRecordType = 'POI' | 'PointAddress' | 'Street';
7976
7917
  * - `countries[0]` → `country`
7977
7918
  * - `poiBrands[0]` → `brand`
7978
7919
  * - `poiCategories` → `categories` (mapped to TomTom numeric category ids)
7979
- * - `position` + `radiusMeters` → `near.coordinates` + `near.radius_km`
7980
- * - `boundingBox` / `boundingBoxes` → `bboxes`
7920
+ * - `geoBias` → `near.coordinates` + `near.radius_km`
7921
+ * - `boundingBoxes` → `bboxes`
7981
7922
  * - `geometries` → `geometries` (Polygon/MultiPolygon passed through; Circle
7982
7923
  * buffered to a Polygon; FeatureCollection flattened to its features)
7983
7924
  * - `municipalities` → `municipalities`
@@ -7989,23 +7930,18 @@ type ExplorationRecordType = 'POI' | 'PointAddress' | 'Street';
7989
7930
  * @ignore
7990
7931
  * @experimental
7991
7932
  */
7992
- type ExplorationSearchParams = CommonSearchParams<ExplorationSearchRequestAPI, ExplorationSearchResponseAPI> & CommonGeocodeAndFuzzySearchParams & {
7933
+ type ExplorationSearchParams = CommonSearchParams<ExplorationSearchRequestAPI, ExplorationSearchResponseAPI> & Omit<CommonGeocodeAndFuzzySearchParams, 'geoBias'> & {
7993
7934
  /**
7994
- * Geographic position to restrict results around.
7995
- *
7996
- * Combined with {@link radiusMeters} this maps to the API's `near` filter.
7997
- * Accepts any {@link HasLngLat}-compatible value — a `[lon, lat]` tuple,
7998
- * a GeoJSON `Point`, or a `Feature<Point>`.
7935
+ * The point to search around, and how far. Unlike the other search services, this endpoint
7936
+ * takes a point and {@link boundingBoxes} as separate filters, so both may be given.
7999
7937
  */
8000
- position?: HasLngLat;
7938
+ geoBias?: PointGeoBias;
8001
7939
  /**
8002
7940
  * Exact, case-sensitive municipality/city filters (e.g. `['Amsterdam', 'Utrecht']`).
8003
7941
  */
8004
7942
  municipalities?: string[];
8005
7943
  /**
8006
- * Additional bounding boxes to restrict results to.
8007
- *
8008
- * Merged with {@link boundingBox} and sent as the API's `bboxes` array.
7944
+ * Bounding boxes to restrict results to, sent as the API's `bboxes` array.
8009
7945
  */
8010
7946
  boundingBoxes?: HasBBox[];
8011
7947
  /**
@@ -9108,30 +9044,6 @@ type FuzzySearchParams = CommonSearchParams<URL, FuzzySearchResponseAPI> & Commo
9108
9044
  * minFuzzyLevel: 2 // Require at least moderate similarity
9109
9045
  * ```
9110
9046
  */
9111
- /**
9112
- * Geographic position to bias search results toward.
9113
- *
9114
- * When provided, results closer to this position are ranked higher.
9115
- * Does not filter results, only creates a soft bias.
9116
- *
9117
- * Accepts any {@link HasLngLat}-compatible value:
9118
- * - `[longitude, latitude]` coordinate pair
9119
- * - GeoJSON `Point` geometry
9120
- * - GeoJSON `Feature<Point>` — pass a {@link Place} directly
9121
- *
9122
- * @example
9123
- * ```typescript
9124
- * // Coordinate pair
9125
- * position: [4.9041, 52.3676]
9126
- *
9127
- * // Place result from a previous search
9128
- * position: searchResults.features[0]
9129
- *
9130
- * // GeoJSON Point
9131
- * position: { type: 'Point', coordinates: [4.9041, 52.3676] }
9132
- * ```
9133
- */
9134
- position?: HasLngLat;
9135
9047
  minFuzzyLevel?: number;
9136
9048
  /**
9137
9049
  * Maximum fuzziness level to be used.