@maptiler/client 1.1.2 → 1.3.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 (76) hide show
  1. package/dist/maptiler-client.cjs +89 -38
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +70 -29
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +89 -38
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +89 -38
  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 +7 -7
  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 +12 -6
  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 +6 -6
  36. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +6 -6
  37. package/docs/types/services_coordinates.XYZ.html +5 -5
  38. package/docs/types/services_data.GetDataOptions.html +6 -6
  39. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +63 -0
  40. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +63 -0
  41. package/docs/types/services_geocoding.Coordinates.html +9 -6
  42. package/docs/types/services_geocoding.FeatureHierarchy.html +9 -6
  43. package/docs/types/services_geocoding.GeocodingFeature.html +9 -6
  44. package/docs/types/services_geocoding.GeocodingOptions.html +10 -26
  45. package/docs/types/services_geocoding.GeocodingSearchResult.html +9 -6
  46. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +70 -0
  47. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +10 -18
  48. package/docs/types/services_geolocation.GeolocationInfoOptions.html +6 -6
  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 +6 -6
  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 +36 -12
  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 +82 -69
  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/examples/test-browser-umd.html +8 -8
  68. package/package.json +1 -1
  69. package/readme.md +3 -3
  70. package/src/index.ts +4 -0
  71. package/src/mapstyle.ts +52 -7
  72. package/src/services/coordinates.ts +2 -2
  73. package/src/services/data.ts +1 -1
  74. package/src/services/geocoding.ts +152 -61
  75. package/src/services/geolocation.ts +1 -1
  76. package/src/services/staticMaps.ts +1 -1
@@ -193,6 +193,30 @@ const customMessages$3 = {
193
193
  400: "Query too long / Invalid parameters",
194
194
  403: "Key is missing, invalid or restricted"
195
195
  };
196
+ function addLanguageGeocodingOptions(searchParams, options) {
197
+ if (options.language == void 0) {
198
+ return;
199
+ }
200
+ const languages = Array.from(
201
+ new Set(
202
+ (Array.isArray(options.language) ? options.language : [options.language]).map(
203
+ (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
204
+ )
205
+ )
206
+ ).join(",");
207
+ searchParams.set("language", languages);
208
+ }
209
+ function addCommonForwardAndReverseGeocodingOptions(searchParams, options) {
210
+ var _a;
211
+ searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
212
+ if (options.limit != void 0) {
213
+ searchParams.set("limit", String(options.limit));
214
+ }
215
+ if (options.types != void 0) {
216
+ searchParams.set("types", options.types.join(","));
217
+ }
218
+ addLanguageGeocodingOptions(searchParams, options);
219
+ }
196
220
  function forward(_0) {
197
221
  return __async$3(this, arguments, function* (query, options = {}) {
198
222
  var _a;
@@ -203,30 +227,27 @@ function forward(_0) {
203
227
  `geocoding/${encodeURIComponent(query)}.json`,
204
228
  defaults.maptilerApiURL
205
229
  );
206
- endpoint.searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
207
- if ("bbox" in options) {
208
- endpoint.searchParams.set("bbox", options.bbox.join(","));
230
+ const { searchParams } = endpoint;
231
+ addCommonForwardAndReverseGeocodingOptions(searchParams, options);
232
+ if (options.bbox != void 0) {
233
+ searchParams.set("bbox", options.bbox.join(","));
209
234
  }
210
- if ("proximity" in options) {
211
- endpoint.searchParams.set("proximity", options.proximity.join(","));
235
+ if (options.proximity != void 0) {
236
+ searchParams.set("proximity", options.proximity.join(","));
212
237
  }
213
- if ("language" in options) {
214
- const languages = Array.from(
215
- new Set(
216
- (Array.isArray(options.language) ? options.language : [options.language]).map(
217
- (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
218
- )
219
- )
220
- ).join(",");
221
- endpoint.searchParams.set("language", languages);
238
+ if (options.country != void 0) {
239
+ searchParams.set("country", options.country.join(","));
240
+ }
241
+ if (options.fuzzyMatch != void 0) {
242
+ searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
243
+ }
244
+ if (options.autocomplete != void 0) {
245
+ searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
222
246
  }
223
247
  const urlWithParams = endpoint.toString();
224
248
  const res = yield callFetch(urlWithParams);
225
249
  if (!res.ok) {
226
- throw new ServiceError(
227
- res,
228
- res.status in customMessages$3 ? customMessages$3[res.status] : ""
229
- );
250
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
230
251
  }
231
252
  const obj = yield res.json();
232
253
  return obj;
@@ -242,24 +263,25 @@ function reverse(_0) {
242
263
  `geocoding/${position[0]},${position[1]}.json`,
243
264
  defaults.maptilerApiURL
244
265
  );
245
- endpoint.searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
246
- if ("language" in options) {
247
- const languages = Array.from(
248
- new Set(
249
- (Array.isArray(options.language) ? options.language : [options.language]).map(
250
- (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
251
- )
252
- )
253
- ).join(",");
254
- endpoint.searchParams.set("language", languages);
266
+ addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
267
+ const urlWithParams = endpoint.toString();
268
+ const res = yield callFetch(urlWithParams);
269
+ if (!res.ok) {
270
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
255
271
  }
272
+ const obj = yield res.json();
273
+ return obj;
274
+ });
275
+ }
276
+ function byId(_0) {
277
+ return __async$3(this, arguments, function* (id, options = {}) {
278
+ var _a;
279
+ const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
280
+ addLanguageGeocodingOptions(endpoint.searchParams, options);
256
281
  const urlWithParams = endpoint.toString();
257
282
  const res = yield callFetch(urlWithParams);
258
283
  if (!res.ok) {
259
- throw new ServiceError(
260
- res,
261
- res.status in customMessages$3 ? customMessages$3[res.status] : ""
262
- );
284
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
263
285
  }
264
286
  const obj = yield res.json();
265
287
  return obj;
@@ -268,6 +290,7 @@ function reverse(_0) {
268
290
  const geocoding = {
269
291
  forward,
270
292
  reverse,
293
+ byId,
271
294
  language: LanguageGeocoding
272
295
  };
273
296
 
@@ -655,6 +678,13 @@ const mapStylePresetList = [
655
678
  description: "",
656
679
  imageURL: ""
657
680
  },
681
+ {
682
+ id: "streets-v2-night",
683
+ name: "Night",
684
+ variantType: "NIGHT",
685
+ description: "",
686
+ imageURL: ""
687
+ },
658
688
  {
659
689
  id: "streets-v2-pastel",
660
690
  name: "Pastel",
@@ -675,6 +705,13 @@ const mapStylePresetList = [
675
705
  variantType: "DEFAULT",
676
706
  description: "",
677
707
  imageURL: ""
708
+ },
709
+ {
710
+ id: "outdoor-v2-dark",
711
+ name: "Dark",
712
+ variantType: "DARK",
713
+ description: "",
714
+ imageURL: ""
678
715
  }
679
716
  ]
680
717
  },
@@ -685,10 +722,17 @@ const mapStylePresetList = [
685
722
  variants: [
686
723
  {
687
724
  id: "winter-v2",
688
- name: "Winter",
725
+ name: "Default",
689
726
  variantType: "DEFAULT",
690
727
  description: "",
691
728
  imageURL: ""
729
+ },
730
+ {
731
+ id: "winter-v2-dark",
732
+ name: "Dark",
733
+ variantType: "DARK",
734
+ description: "",
735
+ imageURL: ""
692
736
  }
693
737
  ]
694
738
  },
@@ -809,6 +853,13 @@ const mapStylePresetList = [
809
853
  description: "",
810
854
  imageURL: ""
811
855
  },
856
+ {
857
+ id: "topo-v2-dark",
858
+ name: "Dark",
859
+ variantType: "DARK",
860
+ description: "",
861
+ imageURL: ""
862
+ },
812
863
  {
813
864
  id: "topo-v2-shiny",
814
865
  name: "Shiny",
@@ -903,26 +954,26 @@ const mapStylePresetList = [
903
954
  ]
904
955
  },
905
956
  {
906
- referenceStyleID: "STAGE",
907
- name: "Stage",
957
+ referenceStyleID: "DATAVIZ",
958
+ name: "Dataviz",
908
959
  description: "",
909
960
  variants: [
910
961
  {
911
- id: "stage",
962
+ id: "dataviz",
912
963
  name: "Default",
913
964
  variantType: "DEFAULT",
914
965
  description: "",
915
966
  imageURL: ""
916
967
  },
917
968
  {
918
- id: "stage-dark",
969
+ id: "dataviz-dark",
919
970
  name: "Dark",
920
971
  variantType: "DARK",
921
972
  description: "",
922
973
  imageURL: ""
923
974
  },
924
975
  {
925
- id: "stage-light",
976
+ id: "dataviz-light",
926
977
  name: "Light",
927
978
  variantType: "LIGHT",
928
979
  description: "",