@nextgis/geocoder 3.0.0-alpha.7 → 3.0.0-alpha.9
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/lib/geocoder.cjs.js +85 -72
- package/lib/geocoder.cjs.js.map +1 -1
- package/lib/geocoder.cjs.prod.js +1 -1
- package/lib/geocoder.cjs.prod.js.map +1 -1
- package/lib/geocoder.esm-browser.js +86 -73
- package/lib/geocoder.esm-browser.js.map +1 -1
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-browser.prod.js.map +1 -1
- package/lib/geocoder.esm-bundler.js +85 -72
- package/lib/geocoder.esm-bundler.js.map +1 -1
- package/lib/geocoder.esm-bundler.prod.js +1 -1
- package/lib/geocoder.esm-bundler.prod.js.map +1 -1
- package/lib/geocoder.global.js +86 -73
- package/lib/geocoder.global.js.map +1 -1
- package/lib/geocoder.global.prod.js +1 -1
- package/lib/geocoder.global.prod.js.map +1 -1
- package/lib/index.d.ts +21 -3
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.9; author: NextGIS */
|
|
2
2
|
function defined(val) {
|
|
3
3
|
return val !== void 0 && val !== null;
|
|
4
4
|
}
|
|
@@ -917,7 +917,7 @@ let Cache = _Cache;
|
|
|
917
917
|
|
|
918
918
|
var pkg = {
|
|
919
919
|
name: "@nextgis/ngw-connector",
|
|
920
|
-
version: "3.0.0-alpha.
|
|
920
|
+
version: "3.0.0-alpha.8",
|
|
921
921
|
_priority: 12,
|
|
922
922
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
923
923
|
main: "index.js",
|
|
@@ -3125,56 +3125,69 @@ var __asyncGenerator = (__this, __arguments, generator) => {
|
|
|
3125
3125
|
};
|
|
3126
3126
|
class NominatimProvider extends BaseProvider {
|
|
3127
3127
|
constructor(options) {
|
|
3128
|
-
super(
|
|
3128
|
+
super();
|
|
3129
|
+
this.options = options;
|
|
3129
3130
|
__publicField(this, "searchUrl", "https://nominatim.openstreetmap.org");
|
|
3130
|
-
__publicField(this, "
|
|
3131
|
+
__publicField(this, "_abortControllers", []);
|
|
3131
3132
|
if (options && options.searchUrl) {
|
|
3132
3133
|
this.searchUrl = options.searchUrl;
|
|
3133
3134
|
}
|
|
3134
3135
|
}
|
|
3135
3136
|
abort() {
|
|
3136
|
-
this.
|
|
3137
|
-
|
|
3137
|
+
this._abortControllers.forEach((controller) => {
|
|
3138
|
+
controller.abort();
|
|
3139
|
+
});
|
|
3140
|
+
this._abortControllers = [];
|
|
3138
3141
|
}
|
|
3139
3142
|
search(val) {
|
|
3140
3143
|
return __asyncGenerator(this, null, function* () {
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
xhr.open("GET", url, true);
|
|
3148
|
-
xhr.onload = () => {
|
|
3149
|
-
try {
|
|
3150
|
-
const geojson = JSON.parse(xhr.responseText);
|
|
3151
|
-
const features = geojson.features.map((x) => {
|
|
3152
|
-
return {
|
|
3153
|
-
geom: x,
|
|
3154
|
-
extent: x.bbox,
|
|
3155
|
-
text: x.properties && x.properties.display_name,
|
|
3156
|
-
query: val
|
|
3157
|
-
};
|
|
3158
|
-
});
|
|
3159
|
-
resolve(features);
|
|
3160
|
-
} catch (er) {
|
|
3161
|
-
reject(er);
|
|
3162
|
-
}
|
|
3163
|
-
};
|
|
3164
|
-
xhr.onerror = (er) => {
|
|
3165
|
-
reject(er);
|
|
3166
|
-
};
|
|
3167
|
-
this._abort.push(xhr.abort);
|
|
3168
|
-
xhr.send();
|
|
3169
|
-
}).catch((er) => {
|
|
3170
|
-
if (er.name === "CancelError") ;
|
|
3171
|
-
throw er;
|
|
3144
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3145
|
+
const params = new URLSearchParams({
|
|
3146
|
+
format: "geojson",
|
|
3147
|
+
polygon_geojson: "1",
|
|
3148
|
+
q: val,
|
|
3149
|
+
limit: ((_b = (_a = this.options) == null ? void 0 : _a.limit) == null ? void 0 : _b.toString()) || "10"
|
|
3172
3150
|
});
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3151
|
+
if ((_c = this.options) == null ? void 0 : _c.countrycodes) {
|
|
3152
|
+
params.append("countrycodes", this.options.countrycodes);
|
|
3153
|
+
}
|
|
3154
|
+
if ((_d = this.options) == null ? void 0 : _d.addressdetails) {
|
|
3155
|
+
params.append("addressdetails", "1");
|
|
3156
|
+
}
|
|
3157
|
+
if ((_e = this.options) == null ? void 0 : _e.language) {
|
|
3158
|
+
params.append("accept-language", this.options.language);
|
|
3159
|
+
}
|
|
3160
|
+
if ((_f = this.options) == null ? void 0 : _f.bounded) {
|
|
3161
|
+
params.append("bounded", "1");
|
|
3162
|
+
}
|
|
3163
|
+
if ((_g = this.options) == null ? void 0 : _g.viewbox) {
|
|
3164
|
+
const [minLon, minLat, maxLon, maxLat] = this.options.viewbox;
|
|
3165
|
+
params.append("viewbox", `${minLon},${minLat},${maxLon},${maxLat}`);
|
|
3166
|
+
}
|
|
3167
|
+
const url = fixUrlStr(`${this.searchUrl}/search?${params.toString()}`);
|
|
3168
|
+
const controller = new AbortController();
|
|
3169
|
+
this._abortControllers.push(controller);
|
|
3170
|
+
try {
|
|
3171
|
+
const response = yield new __await(fetch(url, { signal: controller.signal }));
|
|
3172
|
+
if (!response.ok) {
|
|
3173
|
+
throw new Error(`Network response was not ok: ${response.statusText}`);
|
|
3174
|
+
}
|
|
3175
|
+
const geojson = yield new __await(response.json());
|
|
3176
|
+
const features = geojson.features.map((x) => {
|
|
3177
|
+
return {
|
|
3178
|
+
geom: x,
|
|
3179
|
+
extent: x.bbox,
|
|
3180
|
+
text: x.properties && x.properties.display_name,
|
|
3181
|
+
query: val
|
|
3182
|
+
};
|
|
3183
|
+
});
|
|
3184
|
+
for (const item of features) {
|
|
3185
|
+
item.result = () => this.result(item);
|
|
3186
|
+
yield item;
|
|
3187
|
+
}
|
|
3188
|
+
} catch (error) {
|
|
3189
|
+
if (error.name === "AbortError") ; else {
|
|
3190
|
+
throw error;
|
|
3178
3191
|
}
|
|
3179
3192
|
}
|
|
3180
3193
|
});
|
|
@@ -3188,41 +3201,41 @@ class NominatimProvider extends BaseProvider {
|
|
|
3188
3201
|
}
|
|
3189
3202
|
reverse(coordinates) {
|
|
3190
3203
|
return __asyncGenerator(this, null, function* () {
|
|
3204
|
+
var _a, _b;
|
|
3191
3205
|
const [lng, lat] = coordinates;
|
|
3192
|
-
const
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
const xhr = new XMLHttpRequest();
|
|
3197
|
-
xhr.open("GET", url, true);
|
|
3198
|
-
xhr.onload = () => {
|
|
3199
|
-
try {
|
|
3200
|
-
const geojson = JSON.parse(xhr.responseText);
|
|
3201
|
-
const feature = geojson.features[0];
|
|
3202
|
-
const result = {
|
|
3203
|
-
geom: feature,
|
|
3204
|
-
extent: feature.bbox,
|
|
3205
|
-
text: feature.properties && feature.properties.display_name,
|
|
3206
|
-
query: `${lat}, ${lng}`
|
|
3207
|
-
};
|
|
3208
|
-
resolve(result);
|
|
3209
|
-
} catch (er) {
|
|
3210
|
-
reject(er);
|
|
3211
|
-
}
|
|
3212
|
-
};
|
|
3213
|
-
xhr.onerror = (er) => {
|
|
3214
|
-
reject(er);
|
|
3215
|
-
};
|
|
3216
|
-
this._abort.push(xhr.abort);
|
|
3217
|
-
xhr.send();
|
|
3218
|
-
}).catch((er) => {
|
|
3219
|
-
if (er.name === "CancelError") ;
|
|
3220
|
-
throw er;
|
|
3206
|
+
const params = new URLSearchParams({
|
|
3207
|
+
format: "geojson",
|
|
3208
|
+
lat: lat.toString(),
|
|
3209
|
+
lon: lng.toString()
|
|
3221
3210
|
});
|
|
3222
|
-
|
|
3223
|
-
|
|
3211
|
+
if ((_a = this.options) == null ? void 0 : _a.addressdetails) {
|
|
3212
|
+
params.append("addressdetails", "1");
|
|
3213
|
+
}
|
|
3214
|
+
if ((_b = this.options) == null ? void 0 : _b.language) {
|
|
3215
|
+
params.append("accept-language", this.options.language);
|
|
3216
|
+
}
|
|
3217
|
+
const url = fixUrlStr(`${this.searchUrl}/reverse?${params.toString()}`);
|
|
3218
|
+
const controller = new AbortController();
|
|
3219
|
+
this._abortControllers.push(controller);
|
|
3220
|
+
try {
|
|
3221
|
+
const response = yield new __await(fetch(url, { signal: controller.signal }));
|
|
3222
|
+
if (!response.ok) {
|
|
3223
|
+
throw new Error(`Network response was not ok: ${response.statusText}`);
|
|
3224
|
+
}
|
|
3225
|
+
const geojson = yield new __await(response.json());
|
|
3226
|
+
const feature = geojson.features[0];
|
|
3227
|
+
const item = {
|
|
3228
|
+
geom: feature,
|
|
3229
|
+
extent: feature.bbox,
|
|
3230
|
+
text: feature.properties && feature.properties.display_name,
|
|
3231
|
+
query: `${lat}, ${lng}`
|
|
3232
|
+
};
|
|
3224
3233
|
item.result = () => this.result(item);
|
|
3225
3234
|
yield item;
|
|
3235
|
+
} catch (error) {
|
|
3236
|
+
if (error.name === "AbortError") ; else {
|
|
3237
|
+
throw error;
|
|
3238
|
+
}
|
|
3226
3239
|
}
|
|
3227
3240
|
});
|
|
3228
3241
|
}
|