@maptiler/client 2.7.0 → 3.0.0-rc.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/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
  # MapTiler Client Changelog
2
+
3
+ ## 3.0.0
4
+
5
+ ### ⚠️ Breaking Changes
6
+ - The default styles of Satellite, Hybrid, Dataviz, Outdoor, Winter, Backdrop, Aquarelle, Ocean, Top, Base and Landscape all point to v4 as their default style. V2 styles are still available under under the `_V2` suffixed namespace eg `MapStyle.STREETS_V2.DEFAULT`.
7
+
8
+ ### New Features
9
+ - Adds new option `adjustSearchParams` to all functions in `geocoding` module
10
+
11
+ ### Bug Fixes
12
+ None
13
+
14
+ ### Others
15
+ - Default value of `types` option of Geocoding API Client changed, TSDoc now links to API docs instead of listing the default types explicitly
16
+
2
17
  ## 2.7.0
3
18
 
4
19
  ### New Features
@@ -39,16 +54,12 @@
39
54
 
40
55
 
41
56
  ### Bug fixes
42
- None
57
+ - `math.latitudeToMercatorY` now always returns a value that is valid in Web Mercator context.
43
58
 
44
59
  ### Others
45
60
  - Switches from explicit exported types to inferred types for the `MapStyle`export.
46
61
  - Adds testing for type and member exports.
47
62
 
48
- ## NEXT
49
- ### Bug Fixes
50
- - `math.latitudeToMercatorY` now always returns a value that is valid in Web Mercator context.
51
-
52
63
  ## 2.6.0
53
64
  ### New Features
54
65
  - Bumps 'Streets' & 'Landscape' styles (and their variants) to new v4 styles.
@@ -1037,6 +1037,13 @@ const customMessages$4 = {
1037
1037
  400: "Query too long / Invalid parameters",
1038
1038
  403: "Key is missing, invalid or restricted"
1039
1039
  };
1040
+ function addBaseGeocodingOptions(searchParams, options) {
1041
+ const { adjustSearchParams, apiKey } = options;
1042
+ if (typeof adjustSearchParams === "function") {
1043
+ adjustSearchParams(searchParams);
1044
+ }
1045
+ searchParams.set("key", apiKey ?? config.apiKey);
1046
+ }
1040
1047
  function addLanguageGeocodingOptions(searchParams, options) {
1041
1048
  const { language } = options;
1042
1049
  if (language === void 0) {
@@ -1051,8 +1058,7 @@ function toValidGeocodingLanguageCode(lang) {
1051
1058
  return langInfo?.geocoding ? langInfo.code : null;
1052
1059
  }
1053
1060
  function addCommonForwardAndReverseGeocodingOptions(searchParams, options) {
1054
- const { apiKey, limit, types, excludeTypes } = options;
1055
- searchParams.set("key", apiKey ?? config.apiKey);
1061
+ const { limit, types, excludeTypes } = options;
1056
1062
  if (limit !== void 0) {
1057
1063
  searchParams.set("limit", String(limit));
1058
1064
  }
@@ -1062,10 +1068,8 @@ function addCommonForwardAndReverseGeocodingOptions(searchParams, options) {
1062
1068
  if (excludeTypes !== void 0) {
1063
1069
  searchParams.set("excludeTypes", String(excludeTypes));
1064
1070
  }
1065
- addLanguageGeocodingOptions(searchParams, options);
1066
1071
  }
1067
1072
  function addForwardGeocodingOptions(searchParams, options) {
1068
- addCommonForwardAndReverseGeocodingOptions(searchParams, options);
1069
1073
  const { bbox, proximity, country, fuzzyMatch, autocomplete } = options;
1070
1074
  if (bbox !== void 0) {
1071
1075
  searchParams.set("bbox", bbox.join(","));
@@ -1094,6 +1098,9 @@ async function forward(query, options = {}) {
1094
1098
  `geocoding/${encodeURIComponent(query)}.json`,
1095
1099
  defaults.maptilerApiURL
1096
1100
  );
1101
+ addBaseGeocodingOptions(endpoint.searchParams, options);
1102
+ addLanguageGeocodingOptions(endpoint.searchParams, options);
1103
+ addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
1097
1104
  addForwardGeocodingOptions(endpoint.searchParams, options);
1098
1105
  const res = await callFetch(endpoint.toString());
1099
1106
  if (!res.ok) {
@@ -1109,6 +1116,8 @@ async function reverse(position, options = {}) {
1109
1116
  `geocoding/${position[0]},${position[1]}.json`,
1110
1117
  defaults.maptilerApiURL
1111
1118
  );
1119
+ addBaseGeocodingOptions(endpoint.searchParams, options);
1120
+ addLanguageGeocodingOptions(endpoint.searchParams, options);
1112
1121
  addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
1113
1122
  const res = await callFetch(endpoint.toString());
1114
1123
  if (!res.ok) {
@@ -1118,7 +1127,7 @@ async function reverse(position, options = {}) {
1118
1127
  }
1119
1128
  async function byId(id, options = {}) {
1120
1129
  const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
1121
- endpoint.searchParams.set("key", options.apiKey ?? config.apiKey);
1130
+ addBaseGeocodingOptions(endpoint.searchParams, options);
1122
1131
  addLanguageGeocodingOptions(endpoint.searchParams, options);
1123
1132
  const res = await callFetch(endpoint.toString());
1124
1133
  if (!res.ok) {
@@ -1135,6 +1144,9 @@ async function batch$1(queries, options = {}) {
1135
1144
  `geocoding/${joinedQuery}.json`,
1136
1145
  defaults.maptilerApiURL
1137
1146
  );
1147
+ addBaseGeocodingOptions(endpoint.searchParams, options);
1148
+ addLanguageGeocodingOptions(endpoint.searchParams, options);
1149
+ addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
1138
1150
  addForwardGeocodingOptions(endpoint.searchParams, options);
1139
1151
  const res = await callFetch(endpoint.toString());
1140
1152
  if (!res.ok) {
@@ -2286,19 +2298,20 @@ const MAP_STYLE_CONFIG = [
2286
2298
  }
2287
2299
  ];
2288
2300
  const defaultReferenceStyleMap = {
2289
- STREETS: "STREETS_V2",
2301
+ STREETS: "STREETS_V4",
2290
2302
  BASIC: "BASIC_V2",
2291
- LANDSCAPE: "LANDSCAPE_V2",
2292
- AQUARELLE: "AQUARELLE_V2",
2293
- SATELLITE: "SATELLITE_V2",
2294
- WINTER: "WINTER_V2",
2295
- HYBRID: "HYBRID_V2",
2296
- OCEAN: "OCEAN_V2",
2303
+ BASE: "BASE_V4",
2304
+ LANDSCAPE: "LANDSCAPE_V4",
2305
+ AQUARELLE: "AQUARELLE_V4",
2306
+ SATELLITE: "SATELLITE_V4",
2307
+ WINTER: "WINTER_V4",
2308
+ HYBRID: "HYBRID_V4",
2309
+ OCEAN: "OCEAN_V4",
2297
2310
  TONER: "TONER_V2",
2298
- TOPO: "TOPO_V2",
2311
+ TOPO: "TOPO_V4",
2299
2312
  OPENSTREETMAP: "OPENSTREETMAP_V2",
2300
- DATAVIZ: "DATAVIZ_V2",
2301
- BACKDROP: "BACKDROP_V2",
2313
+ DATAVIZ: "DATAVIZ_V4",
2314
+ BACKDROP: "BACKDROP_V4",
2302
2315
  VOYAGER: "VOYAGER_V2"
2303
2316
  };
2304
2317
  const mapStylePresetList = [
@@ -3307,6 +3320,7 @@ exports.circumferenceAtLatitude = circumferenceAtLatitude;
3307
3320
  exports.config = config;
3308
3321
  exports.coordinates = coordinates;
3309
3322
  exports.data = data;
3323
+ exports.defaultReferenceStyleMap = defaultReferenceStyleMap;
3310
3324
  exports.elevation = elevation;
3311
3325
  exports.expandMapStyle = expandMapStyle;
3312
3326
  exports.geocoding = geocoding;