@maptiler/client 1.1.3 → 1.4.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 +113 -36
- package/dist/maptiler-client.cjs.map +1 -1
- package/dist/maptiler-client.d.ts +79 -28
- package/dist/maptiler-client.min.mjs +1 -1
- package/dist/maptiler-client.mjs +113 -36
- package/dist/maptiler-client.mjs.map +1 -1
- package/dist/maptiler-client.umd.js +113 -36
- 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 +56 -12
- package/docs/variables/services_geolocation.geolocation.html +5 -5
- package/docs/variables/services_staticMaps.staticMaps.html +5 -5
- package/docsmd/README.md +82 -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 +3 -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 +206 -65
- package/src/services/geolocation.ts +1 -1
- package/src/services/staticMaps.ts +1 -1
package/dist/maptiler-client.cjs
CHANGED
|
@@ -193,6 +193,48 @@ 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
|
+
}
|
|
220
|
+
function addForwardGeocodingOptions(searchParams, options) {
|
|
221
|
+
addCommonForwardAndReverseGeocodingOptions(searchParams, options);
|
|
222
|
+
if (options.bbox != void 0) {
|
|
223
|
+
searchParams.set("bbox", options.bbox.join(","));
|
|
224
|
+
}
|
|
225
|
+
if (options.proximity != void 0) {
|
|
226
|
+
searchParams.set("proximity", options.proximity.join(","));
|
|
227
|
+
}
|
|
228
|
+
if (options.country != void 0) {
|
|
229
|
+
searchParams.set("country", options.country.join(","));
|
|
230
|
+
}
|
|
231
|
+
if (options.fuzzyMatch != void 0) {
|
|
232
|
+
searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
|
|
233
|
+
}
|
|
234
|
+
if (options.autocomplete != void 0) {
|
|
235
|
+
searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
196
238
|
function forward(_0) {
|
|
197
239
|
return __async$3(this, arguments, function* (query, options = {}) {
|
|
198
240
|
var _a;
|
|
@@ -203,30 +245,12 @@ function forward(_0) {
|
|
|
203
245
|
`geocoding/${encodeURIComponent(query)}.json`,
|
|
204
246
|
defaults.maptilerApiURL
|
|
205
247
|
);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
endpoint.searchParams.set("bbox", options.bbox.join(","));
|
|
209
|
-
}
|
|
210
|
-
if ("proximity" in options) {
|
|
211
|
-
endpoint.searchParams.set("proximity", options.proximity.join(","));
|
|
212
|
-
}
|
|
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);
|
|
222
|
-
}
|
|
248
|
+
const { searchParams } = endpoint;
|
|
249
|
+
addForwardGeocodingOptions(searchParams, options);
|
|
223
250
|
const urlWithParams = endpoint.toString();
|
|
224
251
|
const res = yield callFetch(urlWithParams);
|
|
225
252
|
if (!res.ok) {
|
|
226
|
-
throw new ServiceError(
|
|
227
|
-
res,
|
|
228
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
229
|
-
);
|
|
253
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
230
254
|
}
|
|
231
255
|
const obj = yield res.json();
|
|
232
256
|
return obj;
|
|
@@ -242,32 +266,57 @@ function reverse(_0) {
|
|
|
242
266
|
`geocoding/${position[0]},${position[1]}.json`,
|
|
243
267
|
defaults.maptilerApiURL
|
|
244
268
|
);
|
|
245
|
-
endpoint.searchParams
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
).join(",");
|
|
254
|
-
endpoint.searchParams.set("language", languages);
|
|
269
|
+
addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
|
|
270
|
+
const urlWithParams = endpoint.toString();
|
|
271
|
+
const res = yield callFetch(urlWithParams);
|
|
272
|
+
if (!res.ok) {
|
|
273
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
255
274
|
}
|
|
275
|
+
const obj = yield res.json();
|
|
276
|
+
return obj;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function byId(_0) {
|
|
280
|
+
return __async$3(this, arguments, function* (id, options = {}) {
|
|
281
|
+
var _a;
|
|
282
|
+
const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
|
|
283
|
+
addLanguageGeocodingOptions(endpoint.searchParams, options);
|
|
256
284
|
const urlWithParams = endpoint.toString();
|
|
257
285
|
const res = yield callFetch(urlWithParams);
|
|
258
286
|
if (!res.ok) {
|
|
259
|
-
throw new ServiceError(
|
|
260
|
-
res,
|
|
261
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
262
|
-
);
|
|
287
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
263
288
|
}
|
|
264
289
|
const obj = yield res.json();
|
|
265
290
|
return obj;
|
|
266
291
|
});
|
|
267
292
|
}
|
|
293
|
+
function batch(_0) {
|
|
294
|
+
return __async$3(this, arguments, function* (queries, options = {}) {
|
|
295
|
+
var _a;
|
|
296
|
+
if (!queries.length) {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
const joinedQuery = queries.map((query) => encodeURIComponent(query)).join(";");
|
|
300
|
+
const endpoint = new URL(
|
|
301
|
+
`geocoding/${joinedQuery}.json`,
|
|
302
|
+
defaults.maptilerApiURL
|
|
303
|
+
);
|
|
304
|
+
const { searchParams } = endpoint;
|
|
305
|
+
addForwardGeocodingOptions(searchParams, options);
|
|
306
|
+
const urlWithParams = endpoint.toString();
|
|
307
|
+
const res = yield callFetch(urlWithParams);
|
|
308
|
+
if (!res.ok) {
|
|
309
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
310
|
+
}
|
|
311
|
+
const obj = yield res.json();
|
|
312
|
+
return queries.length === 1 ? [obj] : obj;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
268
315
|
const geocoding = {
|
|
269
316
|
forward,
|
|
270
317
|
reverse,
|
|
318
|
+
byId,
|
|
319
|
+
batch,
|
|
271
320
|
language: LanguageGeocoding
|
|
272
321
|
};
|
|
273
322
|
|
|
@@ -655,6 +704,13 @@ const mapStylePresetList = [
|
|
|
655
704
|
description: "",
|
|
656
705
|
imageURL: ""
|
|
657
706
|
},
|
|
707
|
+
{
|
|
708
|
+
id: "streets-v2-night",
|
|
709
|
+
name: "Night",
|
|
710
|
+
variantType: "NIGHT",
|
|
711
|
+
description: "",
|
|
712
|
+
imageURL: ""
|
|
713
|
+
},
|
|
658
714
|
{
|
|
659
715
|
id: "streets-v2-pastel",
|
|
660
716
|
name: "Pastel",
|
|
@@ -675,6 +731,13 @@ const mapStylePresetList = [
|
|
|
675
731
|
variantType: "DEFAULT",
|
|
676
732
|
description: "",
|
|
677
733
|
imageURL: ""
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
id: "outdoor-v2-dark",
|
|
737
|
+
name: "Dark",
|
|
738
|
+
variantType: "DARK",
|
|
739
|
+
description: "",
|
|
740
|
+
imageURL: ""
|
|
678
741
|
}
|
|
679
742
|
]
|
|
680
743
|
},
|
|
@@ -685,10 +748,17 @@ const mapStylePresetList = [
|
|
|
685
748
|
variants: [
|
|
686
749
|
{
|
|
687
750
|
id: "winter-v2",
|
|
688
|
-
name: "
|
|
751
|
+
name: "Default",
|
|
689
752
|
variantType: "DEFAULT",
|
|
690
753
|
description: "",
|
|
691
754
|
imageURL: ""
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
id: "winter-v2-dark",
|
|
758
|
+
name: "Dark",
|
|
759
|
+
variantType: "DARK",
|
|
760
|
+
description: "",
|
|
761
|
+
imageURL: ""
|
|
692
762
|
}
|
|
693
763
|
]
|
|
694
764
|
},
|
|
@@ -809,6 +879,13 @@ const mapStylePresetList = [
|
|
|
809
879
|
description: "",
|
|
810
880
|
imageURL: ""
|
|
811
881
|
},
|
|
882
|
+
{
|
|
883
|
+
id: "topo-v2-dark",
|
|
884
|
+
name: "Dark",
|
|
885
|
+
variantType: "DARK",
|
|
886
|
+
description: "",
|
|
887
|
+
imageURL: ""
|
|
888
|
+
},
|
|
812
889
|
{
|
|
813
890
|
id: "topo-v2-shiny",
|
|
814
891
|
name: "Shiny",
|