@maptiler/client 3.1.0-rc.4 → 3.1.0-rc.5

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.
@@ -1315,6 +1315,13 @@ function addProfileOptions(search, profile, opts) {
1315
1315
  search.set("pedestrian.walkingSpeed", String(o.walkingSpeed));
1316
1316
  }
1317
1317
  }
1318
+ function addRoutingOptions(search, options) {
1319
+ const { adjustSearchParams } = options;
1320
+ if (typeof adjustSearchParams === "function") {
1321
+ adjustSearchParams(search);
1322
+ }
1323
+ search.set("key", config.apiKey);
1324
+ }
1318
1325
  function decodeLegGeometry(leg) {
1319
1326
  if (typeof leg.geometry === "string") {
1320
1327
  return decode(leg.geometry, 6).map(([lat, lon]) => [lon, lat]);
@@ -1338,9 +1345,10 @@ async function processDirectionsResponse(res) {
1338
1345
  }
1339
1346
  return response;
1340
1347
  }
1341
- async function directionsPost(body, fetchExtras) {
1348
+ async function directionsPost(body, options = {}) {
1349
+ const { fetchExtras } = options;
1342
1350
  const url = new URL("routing/v1/directions", defaults.maptilerApiURL);
1343
- url.searchParams.set("key", config.apiKey);
1351
+ addRoutingOptions(url.searchParams, options);
1344
1352
  const headers = new Headers(fetchExtras?.headers);
1345
1353
  headers.set("content-type", "application/json");
1346
1354
  const res = await callFetch(url.toString(), {
@@ -1351,10 +1359,10 @@ async function directionsPost(body, fetchExtras) {
1351
1359
  });
1352
1360
  return await processDirectionsResponse(res);
1353
1361
  }
1354
- async function directionsGet(req, fetchExtras) {
1362
+ async function directionsGet(req, options = {}) {
1363
+ const { fetchExtras } = options;
1355
1364
  const url = new URL("routing/v1/directions", defaults.maptilerApiURL);
1356
1365
  const search = url.searchParams;
1357
- search.set("key", config.apiKey);
1358
1366
  search.set("profile", req.profile);
1359
1367
  if (req.id) search.set("id", req.id);
1360
1368
  if (req.departureTime) search.set("departureTime", req.departureTime);
@@ -1362,6 +1370,7 @@ async function directionsGet(req, fetchExtras) {
1362
1370
  addLocations(search, req.locations);
1363
1371
  addResponseOptions(search, req.response);
1364
1372
  addProfileOptions(search, req.profile, req.profileOptions);
1373
+ addRoutingOptions(search, options);
1365
1374
  const res = await callFetch(url.toString(), {
1366
1375
  ...fetchExtras,
1367
1376
  method: "GET",