@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
|
@@ -195,6 +195,48 @@
|
|
|
195
195
|
400: "Query too long / Invalid parameters",
|
|
196
196
|
403: "Key is missing, invalid or restricted"
|
|
197
197
|
};
|
|
198
|
+
function addLanguageGeocodingOptions(searchParams, options) {
|
|
199
|
+
if (options.language == void 0) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const languages = Array.from(
|
|
203
|
+
new Set(
|
|
204
|
+
(Array.isArray(options.language) ? options.language : [options.language]).map(
|
|
205
|
+
(lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
|
|
206
|
+
)
|
|
207
|
+
)
|
|
208
|
+
).join(",");
|
|
209
|
+
searchParams.set("language", languages);
|
|
210
|
+
}
|
|
211
|
+
function addCommonForwardAndReverseGeocodingOptions(searchParams, options) {
|
|
212
|
+
var _a;
|
|
213
|
+
searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
|
|
214
|
+
if (options.limit != void 0) {
|
|
215
|
+
searchParams.set("limit", String(options.limit));
|
|
216
|
+
}
|
|
217
|
+
if (options.types != void 0) {
|
|
218
|
+
searchParams.set("types", options.types.join(","));
|
|
219
|
+
}
|
|
220
|
+
addLanguageGeocodingOptions(searchParams, options);
|
|
221
|
+
}
|
|
222
|
+
function addForwardGeocodingOptions(searchParams, options) {
|
|
223
|
+
addCommonForwardAndReverseGeocodingOptions(searchParams, options);
|
|
224
|
+
if (options.bbox != void 0) {
|
|
225
|
+
searchParams.set("bbox", options.bbox.join(","));
|
|
226
|
+
}
|
|
227
|
+
if (options.proximity != void 0) {
|
|
228
|
+
searchParams.set("proximity", options.proximity.join(","));
|
|
229
|
+
}
|
|
230
|
+
if (options.country != void 0) {
|
|
231
|
+
searchParams.set("country", options.country.join(","));
|
|
232
|
+
}
|
|
233
|
+
if (options.fuzzyMatch != void 0) {
|
|
234
|
+
searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
|
|
235
|
+
}
|
|
236
|
+
if (options.autocomplete != void 0) {
|
|
237
|
+
searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
198
240
|
function forward(_0) {
|
|
199
241
|
return __async$3(this, arguments, function* (query, options = {}) {
|
|
200
242
|
var _a;
|
|
@@ -205,30 +247,12 @@
|
|
|
205
247
|
`geocoding/${encodeURIComponent(query)}.json`,
|
|
206
248
|
defaults.maptilerApiURL
|
|
207
249
|
);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
endpoint.searchParams.set("bbox", options.bbox.join(","));
|
|
211
|
-
}
|
|
212
|
-
if ("proximity" in options) {
|
|
213
|
-
endpoint.searchParams.set("proximity", options.proximity.join(","));
|
|
214
|
-
}
|
|
215
|
-
if ("language" in options) {
|
|
216
|
-
const languages = Array.from(
|
|
217
|
-
new Set(
|
|
218
|
-
(Array.isArray(options.language) ? options.language : [options.language]).map(
|
|
219
|
-
(lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
|
|
220
|
-
)
|
|
221
|
-
)
|
|
222
|
-
).join(",");
|
|
223
|
-
endpoint.searchParams.set("language", languages);
|
|
224
|
-
}
|
|
250
|
+
const { searchParams } = endpoint;
|
|
251
|
+
addForwardGeocodingOptions(searchParams, options);
|
|
225
252
|
const urlWithParams = endpoint.toString();
|
|
226
253
|
const res = yield callFetch(urlWithParams);
|
|
227
254
|
if (!res.ok) {
|
|
228
|
-
throw new ServiceError(
|
|
229
|
-
res,
|
|
230
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
231
|
-
);
|
|
255
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
232
256
|
}
|
|
233
257
|
const obj = yield res.json();
|
|
234
258
|
return obj;
|
|
@@ -244,32 +268,57 @@
|
|
|
244
268
|
`geocoding/${position[0]},${position[1]}.json`,
|
|
245
269
|
defaults.maptilerApiURL
|
|
246
270
|
);
|
|
247
|
-
endpoint.searchParams
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
(lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
|
|
253
|
-
)
|
|
254
|
-
)
|
|
255
|
-
).join(",");
|
|
256
|
-
endpoint.searchParams.set("language", languages);
|
|
271
|
+
addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
|
|
272
|
+
const urlWithParams = endpoint.toString();
|
|
273
|
+
const res = yield callFetch(urlWithParams);
|
|
274
|
+
if (!res.ok) {
|
|
275
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
257
276
|
}
|
|
277
|
+
const obj = yield res.json();
|
|
278
|
+
return obj;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function byId(_0) {
|
|
282
|
+
return __async$3(this, arguments, function* (id, options = {}) {
|
|
283
|
+
var _a;
|
|
284
|
+
const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
|
|
285
|
+
addLanguageGeocodingOptions(endpoint.searchParams, options);
|
|
258
286
|
const urlWithParams = endpoint.toString();
|
|
259
287
|
const res = yield callFetch(urlWithParams);
|
|
260
288
|
if (!res.ok) {
|
|
261
|
-
throw new ServiceError(
|
|
262
|
-
res,
|
|
263
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
264
|
-
);
|
|
289
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
265
290
|
}
|
|
266
291
|
const obj = yield res.json();
|
|
267
292
|
return obj;
|
|
268
293
|
});
|
|
269
294
|
}
|
|
295
|
+
function batch(_0) {
|
|
296
|
+
return __async$3(this, arguments, function* (queries, options = {}) {
|
|
297
|
+
var _a;
|
|
298
|
+
if (!queries.length) {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
const joinedQuery = queries.map((query) => encodeURIComponent(query)).join(";");
|
|
302
|
+
const endpoint = new URL(
|
|
303
|
+
`geocoding/${joinedQuery}.json`,
|
|
304
|
+
defaults.maptilerApiURL
|
|
305
|
+
);
|
|
306
|
+
const { searchParams } = endpoint;
|
|
307
|
+
addForwardGeocodingOptions(searchParams, options);
|
|
308
|
+
const urlWithParams = endpoint.toString();
|
|
309
|
+
const res = yield callFetch(urlWithParams);
|
|
310
|
+
if (!res.ok) {
|
|
311
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
312
|
+
}
|
|
313
|
+
const obj = yield res.json();
|
|
314
|
+
return queries.length === 1 ? [obj] : obj;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
270
317
|
const geocoding = {
|
|
271
318
|
forward,
|
|
272
319
|
reverse,
|
|
320
|
+
byId,
|
|
321
|
+
batch,
|
|
273
322
|
language: LanguageGeocoding
|
|
274
323
|
};
|
|
275
324
|
|
|
@@ -657,6 +706,13 @@
|
|
|
657
706
|
description: "",
|
|
658
707
|
imageURL: ""
|
|
659
708
|
},
|
|
709
|
+
{
|
|
710
|
+
id: "streets-v2-night",
|
|
711
|
+
name: "Night",
|
|
712
|
+
variantType: "NIGHT",
|
|
713
|
+
description: "",
|
|
714
|
+
imageURL: ""
|
|
715
|
+
},
|
|
660
716
|
{
|
|
661
717
|
id: "streets-v2-pastel",
|
|
662
718
|
name: "Pastel",
|
|
@@ -677,6 +733,13 @@
|
|
|
677
733
|
variantType: "DEFAULT",
|
|
678
734
|
description: "",
|
|
679
735
|
imageURL: ""
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
id: "outdoor-v2-dark",
|
|
739
|
+
name: "Dark",
|
|
740
|
+
variantType: "DARK",
|
|
741
|
+
description: "",
|
|
742
|
+
imageURL: ""
|
|
680
743
|
}
|
|
681
744
|
]
|
|
682
745
|
},
|
|
@@ -687,10 +750,17 @@
|
|
|
687
750
|
variants: [
|
|
688
751
|
{
|
|
689
752
|
id: "winter-v2",
|
|
690
|
-
name: "
|
|
753
|
+
name: "Default",
|
|
691
754
|
variantType: "DEFAULT",
|
|
692
755
|
description: "",
|
|
693
756
|
imageURL: ""
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
id: "winter-v2-dark",
|
|
760
|
+
name: "Dark",
|
|
761
|
+
variantType: "DARK",
|
|
762
|
+
description: "",
|
|
763
|
+
imageURL: ""
|
|
694
764
|
}
|
|
695
765
|
]
|
|
696
766
|
},
|
|
@@ -811,6 +881,13 @@
|
|
|
811
881
|
description: "",
|
|
812
882
|
imageURL: ""
|
|
813
883
|
},
|
|
884
|
+
{
|
|
885
|
+
id: "topo-v2-dark",
|
|
886
|
+
name: "Dark",
|
|
887
|
+
variantType: "DARK",
|
|
888
|
+
description: "",
|
|
889
|
+
imageURL: ""
|
|
890
|
+
},
|
|
814
891
|
{
|
|
815
892
|
id: "topo-v2-shiny",
|
|
816
893
|
name: "Shiny",
|