@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
|
@@ -195,6 +195,30 @@
|
|
|
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
|
+
}
|
|
198
222
|
function forward(_0) {
|
|
199
223
|
return __async$3(this, arguments, function* (query, options = {}) {
|
|
200
224
|
var _a;
|
|
@@ -205,30 +229,27 @@
|
|
|
205
229
|
`geocoding/${encodeURIComponent(query)}.json`,
|
|
206
230
|
defaults.maptilerApiURL
|
|
207
231
|
);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
232
|
+
const { searchParams } = endpoint;
|
|
233
|
+
addCommonForwardAndReverseGeocodingOptions(searchParams, options);
|
|
234
|
+
if (options.bbox != void 0) {
|
|
235
|
+
searchParams.set("bbox", options.bbox.join(","));
|
|
211
236
|
}
|
|
212
|
-
if (
|
|
213
|
-
|
|
237
|
+
if (options.proximity != void 0) {
|
|
238
|
+
searchParams.set("proximity", options.proximity.join(","));
|
|
214
239
|
}
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
endpoint.searchParams.set("language", languages);
|
|
240
|
+
if (options.country != void 0) {
|
|
241
|
+
searchParams.set("country", options.country.join(","));
|
|
242
|
+
}
|
|
243
|
+
if (options.fuzzyMatch != void 0) {
|
|
244
|
+
searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
|
|
245
|
+
}
|
|
246
|
+
if (options.autocomplete != void 0) {
|
|
247
|
+
searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
|
|
224
248
|
}
|
|
225
249
|
const urlWithParams = endpoint.toString();
|
|
226
250
|
const res = yield callFetch(urlWithParams);
|
|
227
251
|
if (!res.ok) {
|
|
228
|
-
throw new ServiceError(
|
|
229
|
-
res,
|
|
230
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
231
|
-
);
|
|
252
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
232
253
|
}
|
|
233
254
|
const obj = yield res.json();
|
|
234
255
|
return obj;
|
|
@@ -244,24 +265,25 @@
|
|
|
244
265
|
`geocoding/${position[0]},${position[1]}.json`,
|
|
245
266
|
defaults.maptilerApiURL
|
|
246
267
|
);
|
|
247
|
-
endpoint.searchParams
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
(lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
|
|
253
|
-
)
|
|
254
|
-
)
|
|
255
|
-
).join(",");
|
|
256
|
-
endpoint.searchParams.set("language", languages);
|
|
268
|
+
addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
|
|
269
|
+
const urlWithParams = endpoint.toString();
|
|
270
|
+
const res = yield callFetch(urlWithParams);
|
|
271
|
+
if (!res.ok) {
|
|
272
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
257
273
|
}
|
|
274
|
+
const obj = yield res.json();
|
|
275
|
+
return obj;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
function byId(_0) {
|
|
279
|
+
return __async$3(this, arguments, function* (id, options = {}) {
|
|
280
|
+
var _a;
|
|
281
|
+
const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
|
|
282
|
+
addLanguageGeocodingOptions(endpoint.searchParams, options);
|
|
258
283
|
const urlWithParams = endpoint.toString();
|
|
259
284
|
const res = yield callFetch(urlWithParams);
|
|
260
285
|
if (!res.ok) {
|
|
261
|
-
throw new ServiceError(
|
|
262
|
-
res,
|
|
263
|
-
res.status in customMessages$3 ? customMessages$3[res.status] : ""
|
|
264
|
-
);
|
|
286
|
+
throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
|
|
265
287
|
}
|
|
266
288
|
const obj = yield res.json();
|
|
267
289
|
return obj;
|
|
@@ -270,6 +292,7 @@
|
|
|
270
292
|
const geocoding = {
|
|
271
293
|
forward,
|
|
272
294
|
reverse,
|
|
295
|
+
byId,
|
|
273
296
|
language: LanguageGeocoding
|
|
274
297
|
};
|
|
275
298
|
|
|
@@ -657,6 +680,13 @@
|
|
|
657
680
|
description: "",
|
|
658
681
|
imageURL: ""
|
|
659
682
|
},
|
|
683
|
+
{
|
|
684
|
+
id: "streets-v2-night",
|
|
685
|
+
name: "Night",
|
|
686
|
+
variantType: "NIGHT",
|
|
687
|
+
description: "",
|
|
688
|
+
imageURL: ""
|
|
689
|
+
},
|
|
660
690
|
{
|
|
661
691
|
id: "streets-v2-pastel",
|
|
662
692
|
name: "Pastel",
|
|
@@ -677,6 +707,13 @@
|
|
|
677
707
|
variantType: "DEFAULT",
|
|
678
708
|
description: "",
|
|
679
709
|
imageURL: ""
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: "outdoor-v2-dark",
|
|
713
|
+
name: "Dark",
|
|
714
|
+
variantType: "DARK",
|
|
715
|
+
description: "",
|
|
716
|
+
imageURL: ""
|
|
680
717
|
}
|
|
681
718
|
]
|
|
682
719
|
},
|
|
@@ -687,10 +724,17 @@
|
|
|
687
724
|
variants: [
|
|
688
725
|
{
|
|
689
726
|
id: "winter-v2",
|
|
690
|
-
name: "
|
|
727
|
+
name: "Default",
|
|
691
728
|
variantType: "DEFAULT",
|
|
692
729
|
description: "",
|
|
693
730
|
imageURL: ""
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
id: "winter-v2-dark",
|
|
734
|
+
name: "Dark",
|
|
735
|
+
variantType: "DARK",
|
|
736
|
+
description: "",
|
|
737
|
+
imageURL: ""
|
|
694
738
|
}
|
|
695
739
|
]
|
|
696
740
|
},
|
|
@@ -811,6 +855,13 @@
|
|
|
811
855
|
description: "",
|
|
812
856
|
imageURL: ""
|
|
813
857
|
},
|
|
858
|
+
{
|
|
859
|
+
id: "topo-v2-dark",
|
|
860
|
+
name: "Dark",
|
|
861
|
+
variantType: "DARK",
|
|
862
|
+
description: "",
|
|
863
|
+
imageURL: ""
|
|
864
|
+
},
|
|
814
865
|
{
|
|
815
866
|
id: "topo-v2-shiny",
|
|
816
867
|
name: "Shiny",
|