@maptiler/client 1.1.3 → 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.
- package/dist/maptiler-client.cjs +84 -33
- package/dist/maptiler-client.cjs.map +1 -1
- package/dist/maptiler-client.d.ts +69 -28
- package/dist/maptiler-client.min.mjs +1 -1
- package/dist/maptiler-client.mjs +84 -33
- package/dist/maptiler-client.mjs.map +1 -1
- package/dist/maptiler-client.umd.js +84 -33
- package/dist/maptiler-client.umd.js.map +1 -1
- package/dist/maptiler-client.umd.min.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/config.ClientConfig.html +9 -9
- package/docs/classes/services_ServiceError.ServiceError.html +7 -7
- package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
- package/docs/functions/services_simplify.default.html +5 -5
- package/docs/index.html +4 -4
- package/docs/modules/config.html +5 -5
- package/docs/modules/language.html +5 -5
- package/docs/modules/services_ServiceError.html +5 -5
- package/docs/modules/services_coordinates.html +5 -5
- package/docs/modules/services_data.html +5 -5
- package/docs/modules/services_geocoding.html +12 -6
- package/docs/modules/services_geolocation.html +5 -5
- package/docs/modules/services_simplify.html +5 -5
- package/docs/modules/services_staticMaps.html +5 -5
- package/docs/modules.html +4 -4
- package/docs/types/config.FetchFunction.html +5 -5
- package/docs/types/language.LanguageGeocodingString.html +5 -5
- package/docs/types/services_coordinates.CoordinateExport.html +5 -5
- package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
- package/docs/types/services_coordinates.CoordinateId.html +5 -5
- package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
- package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
- package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
- package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
- package/docs/types/services_coordinates.CoordinatesSearchOptions.html +6 -6
- package/docs/types/services_coordinates.CoordinatesTransformOptions.html +6 -6
- package/docs/types/services_coordinates.XYZ.html +5 -5
- package/docs/types/services_data.GetDataOptions.html +6 -6
- package/docs/types/services_geocoding.ByIdGeocodingOptions.html +63 -0
- package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +63 -0
- package/docs/types/services_geocoding.Coordinates.html +9 -6
- package/docs/types/services_geocoding.FeatureHierarchy.html +9 -6
- package/docs/types/services_geocoding.GeocodingFeature.html +9 -6
- package/docs/types/services_geocoding.GeocodingOptions.html +10 -26
- package/docs/types/services_geocoding.GeocodingSearchResult.html +9 -6
- package/docs/types/services_geocoding.LanguageGeocodingOptions.html +70 -0
- package/docs/types/services_geocoding.ReverseGeocodingOptions.html +10 -18
- package/docs/types/services_geolocation.GeolocationInfoOptions.html +6 -6
- package/docs/types/services_geolocation.GeolocationResult.html +5 -5
- package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.StaticMapBaseOptions.html +6 -6
- package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
- package/docs/variables/config.config.html +5 -5
- package/docs/variables/language.LanguageGeocoding.html +5 -5
- package/docs/variables/services_coordinates.coordinates.html +5 -5
- package/docs/variables/services_data.data.html +5 -5
- package/docs/variables/services_geocoding.geocoding.html +36 -12
- package/docs/variables/services_geolocation.geolocation.html +5 -5
- package/docs/variables/services_staticMaps.staticMaps.html +5 -5
- package/docsmd/README.md +81 -68
- package/docsmd/classes/ClientConfig.md +5 -5
- package/docsmd/classes/MapStyleVariant.md +13 -13
- package/docsmd/classes/ReferenceMapStyle.md +9 -9
- package/docsmd/classes/ServiceError.md +3 -3
- package/examples/test-browser-umd.html +6 -6
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/mapstyle.ts +46 -1
- package/src/services/coordinates.ts +2 -2
- package/src/services/data.ts +1 -1
- package/src/services/geocoding.ts +152 -61
- package/src/services/geolocation.ts +1 -1
- package/src/services/staticMaps.ts +1 -1
package/dist/maptiler-client.cjs
CHANGED
|
@@ -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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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 (
|
|
211
|
-
|
|
235
|
+
if (options.proximity != void 0) {
|
|
236
|
+
searchParams.set("proximity", options.proximity.join(","));
|
|
212
237
|
}
|
|
213
|
-
if (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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: "
|
|
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",
|