@maptiler/client 1.3.0 → 1.5.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.
Files changed (70) hide show
  1. package/dist/maptiler-client.cjs +70 -16
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +27 -0
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +70 -16
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +70 -16
  8. package/dist/maptiler-client.umd.js.map +1 -1
  9. package/dist/maptiler-client.umd.min.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/classes/config.ClientConfig.html +9 -9
  12. package/docs/classes/services_ServiceError.ServiceError.html +7 -7
  13. package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
  14. package/docs/functions/services_simplify.default.html +5 -5
  15. package/docs/index.html +16 -10
  16. package/docs/modules/config.html +5 -5
  17. package/docs/modules/language.html +5 -5
  18. package/docs/modules/services_ServiceError.html +5 -5
  19. package/docs/modules/services_coordinates.html +5 -5
  20. package/docs/modules/services_data.html +5 -5
  21. package/docs/modules/services_geocoding.html +5 -5
  22. package/docs/modules/services_geolocation.html +5 -5
  23. package/docs/modules/services_simplify.html +5 -5
  24. package/docs/modules/services_staticMaps.html +5 -5
  25. package/docs/modules.html +4 -4
  26. package/docs/types/config.FetchFunction.html +5 -5
  27. package/docs/types/language.LanguageGeocodingString.html +5 -5
  28. package/docs/types/services_coordinates.CoordinateExport.html +5 -5
  29. package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
  30. package/docs/types/services_coordinates.CoordinateId.html +5 -5
  31. package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
  32. package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
  33. package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
  34. package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
  35. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +5 -5
  36. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +5 -5
  37. package/docs/types/services_coordinates.XYZ.html +5 -5
  38. package/docs/types/services_data.GetDataOptions.html +5 -5
  39. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +5 -5
  40. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +5 -5
  41. package/docs/types/services_geocoding.Coordinates.html +5 -5
  42. package/docs/types/services_geocoding.FeatureHierarchy.html +5 -5
  43. package/docs/types/services_geocoding.GeocodingFeature.html +5 -5
  44. package/docs/types/services_geocoding.GeocodingOptions.html +5 -5
  45. package/docs/types/services_geocoding.GeocodingSearchResult.html +5 -5
  46. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +5 -5
  47. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +5 -5
  48. package/docs/types/services_geolocation.GeolocationInfoOptions.html +5 -5
  49. package/docs/types/services_geolocation.GeolocationResult.html +5 -5
  50. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
  51. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
  52. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
  53. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +5 -5
  54. package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
  55. package/docs/variables/config.config.html +5 -5
  56. package/docs/variables/language.LanguageGeocoding.html +5 -5
  57. package/docs/variables/services_coordinates.coordinates.html +5 -5
  58. package/docs/variables/services_data.data.html +5 -5
  59. package/docs/variables/services_geocoding.geocoding.html +29 -9
  60. package/docs/variables/services_geolocation.geolocation.html +5 -5
  61. package/docs/variables/services_staticMaps.staticMaps.html +5 -5
  62. package/docsmd/README.md +44 -42
  63. package/docsmd/classes/ClientConfig.md +5 -5
  64. package/docsmd/classes/MapStyleVariant.md +13 -13
  65. package/docsmd/classes/ReferenceMapStyle.md +9 -9
  66. package/docsmd/classes/ServiceError.md +3 -3
  67. package/package.json +3 -1
  68. package/readme.md +8 -4
  69. package/src/mapstyle.ts +49 -0
  70. package/src/services/geocoding.ts +71 -21
package/src/mapstyle.ts CHANGED
@@ -478,6 +478,26 @@ export type MapStyleType = {
478
478
  */
479
479
  DEFAULT: MapStyleVariant;
480
480
  };
481
+
482
+ /**
483
+ * Neutral greyscale style with hillshading suitable for colorful terrain-aware visualization
484
+ */
485
+ BACKDROP: ReferenceMapStyle & {
486
+ /**
487
+ * Neutral greyscale style with hillshading suitable for colorful terrain-aware visualization
488
+ */
489
+ DEFAULT: MapStyleVariant;
490
+
491
+ /**
492
+ * Dark greyscale style with hillshading suitable for colorful terrain-aware visualization
493
+ */
494
+ DARK: MapStyleVariant;
495
+
496
+ /**
497
+ * Light greyscale style with hillshading suitable for colorful terrain-aware visualization
498
+ */
499
+ LIGHT: MapStyleVariant;
500
+ };
481
501
  };
482
502
 
483
503
  export const mapStylePresetList: Array<MapStylePreset> = [
@@ -822,6 +842,35 @@ export const mapStylePresetList: Array<MapStylePreset> = [
822
842
  ],
823
843
  },
824
844
 
845
+ {
846
+ referenceStyleID: "BACKDROP",
847
+ name: "Backdrop",
848
+ description: "",
849
+ variants: [
850
+ {
851
+ id: "backdrop",
852
+ name: "Default",
853
+ variantType: "DEFAULT",
854
+ description: "",
855
+ imageURL: "",
856
+ },
857
+ {
858
+ id: "backdrop-dark",
859
+ name: "Dark",
860
+ variantType: "DARK",
861
+ description: "",
862
+ imageURL: "",
863
+ },
864
+ {
865
+ id: "backdrop-light",
866
+ name: "Light",
867
+ variantType: "LIGHT",
868
+ description: "",
869
+ imageURL: "",
870
+ },
871
+ ],
872
+ },
873
+
825
874
  {
826
875
  referenceStyleID: "OCEAN",
827
876
  name: "Ocean",
@@ -190,6 +190,33 @@ function addCommonForwardAndReverseGeocodingOptions(
190
190
  addLanguageGeocodingOptions(searchParams, options);
191
191
  }
192
192
 
193
+ function addForwardGeocodingOptions(
194
+ searchParams: URLSearchParams,
195
+ options: GeocodingOptions
196
+ ) {
197
+ addCommonForwardAndReverseGeocodingOptions(searchParams, options);
198
+
199
+ if (options.bbox != undefined) {
200
+ searchParams.set("bbox", options.bbox.join(","));
201
+ }
202
+
203
+ if (options.proximity != undefined) {
204
+ searchParams.set("proximity", options.proximity.join(","));
205
+ }
206
+
207
+ if (options.country != undefined) {
208
+ searchParams.set("country", options.country.join(","));
209
+ }
210
+
211
+ if (options.fuzzyMatch != undefined) {
212
+ searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
213
+ }
214
+
215
+ if (options.autocomplete != undefined) {
216
+ searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
217
+ }
218
+ }
219
+
193
220
  /**
194
221
  * Performs a forward geocoding query to MapTiler API.
195
222
  * Providing a human readable place name (of a city, country, street, etc.), the function returns
@@ -214,27 +241,7 @@ async function forward(
214
241
 
215
242
  const { searchParams } = endpoint;
216
243
 
217
- addCommonForwardAndReverseGeocodingOptions(searchParams, options);
218
-
219
- if (options.bbox != undefined) {
220
- searchParams.set("bbox", options.bbox.join(","));
221
- }
222
-
223
- if (options.proximity != undefined) {
224
- searchParams.set("proximity", options.proximity.join(","));
225
- }
226
-
227
- if (options.country != undefined) {
228
- searchParams.set("country", options.country.join(","));
229
- }
230
-
231
- if (options.fuzzyMatch != undefined) {
232
- searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
233
- }
234
-
235
- if (options.autocomplete != undefined) {
236
- searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
237
- }
244
+ addForwardGeocodingOptions(searchParams, options);
238
245
 
239
246
  const urlWithParams = endpoint.toString();
240
247
 
@@ -315,6 +322,48 @@ async function byId(
315
322
  return obj;
316
323
  }
317
324
 
325
+ /**
326
+ * Perform a batch geocoding query to MapTiler API.
327
+ * Provide multiple queries in the array. Each query can be forward, reverse or by feature ID.
328
+ * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/geocoding/#batch-geocoding
329
+ * @param queries
330
+ * @param options
331
+ * @returns
332
+ */
333
+ async function batch(
334
+ queries: string[],
335
+ options: GeocodingOptions = {}
336
+ ): Promise<GeocodingSearchResult[]> {
337
+ if (!queries.length) {
338
+ return [];
339
+ }
340
+
341
+ const joinedQuery = queries
342
+ .map((query) => encodeURIComponent(query))
343
+ .join(";");
344
+
345
+ const endpoint = new URL(
346
+ `geocoding/${joinedQuery}.json`,
347
+ defaults.maptilerApiURL
348
+ );
349
+
350
+ const { searchParams } = endpoint;
351
+
352
+ addForwardGeocodingOptions(searchParams, options);
353
+
354
+ const urlWithParams = endpoint.toString();
355
+
356
+ const res = await callFetch(urlWithParams);
357
+
358
+ if (!res.ok) {
359
+ throw new ServiceError(res, customMessages[res.status] ?? "");
360
+ }
361
+
362
+ const obj = await res.json();
363
+
364
+ return queries.length === 1 ? [obj] : obj;
365
+ }
366
+
318
367
  /**
319
368
  * The **geocoding** namespace contains asynchronous functions to call the [MapTiler Geocoding API](https://docs.maptiler.com/cloud/api/geocoding/).
320
369
  * The **Geocoding API** provides ways to get geographic coordinates from a human-readable search query of a place (forward geocoding)
@@ -324,6 +373,7 @@ const geocoding = {
324
373
  forward,
325
374
  reverse,
326
375
  byId,
376
+ batch,
327
377
  language: LanguageGeocoding,
328
378
  };
329
379