@maptiler/geocoding-control 1.4.2-dev.3 → 2.0.0-rc.1
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/MapLibreBasedGeocodingControl.d.ts +2971 -35
- package/leaflet-controller.d.ts +1 -1
- package/leaflet-controller.js +580 -569
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +3 -3
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.d.ts +74 -16
- package/leaflet.js +1375 -1344
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +3 -3
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.d.ts +7 -7
- package/maplibregl-controller.js +683 -661
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +3 -3
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.js +1596 -1447
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.js +1604 -1452
- package/maptilersdk.js.map +1 -1
- package/maptilersdk.umd.js +3 -3
- package/maptilersdk.umd.js.map +1 -1
- package/openlayers-controller.d.ts +1 -1
- package/openlayers-controller.js +308 -306
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +3 -3
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.d.ts +21 -0
- package/openlayers.js +1352 -1366
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +3 -3
- package/openlayers.umd.js.map +1 -1
- package/package.json +18 -18
- package/react.d.ts +4 -4
- package/react.js +805 -788
- package/react.js.map +1 -1
- package/react.umd.js +1 -1
- package/react.umd.js.map +1 -1
- package/style.css +1 -1
- package/svelte/FeatureItem.svelte.d.ts +1 -1
- package/svelte/GeocodingControl.svelte +61 -32
- package/svelte/GeocodingControl.svelte.d.ts +24 -9
- package/svelte/MapLibreBasedGeocodingControl.d.ts +2971 -35
- package/svelte/MapLibreBasedGeocodingControl.js +166 -58
- package/svelte/leaflet-controller.d.ts +1 -1
- package/svelte/leaflet-controller.js +50 -24
- package/svelte/leaflet.d.ts +74 -16
- package/svelte/leaflet.js +25 -15
- package/svelte/maplibregl-controller.d.ts +7 -7
- package/svelte/maplibregl-controller.js +96 -66
- package/svelte/maplibregl.js +10 -7
- package/svelte/maptilersdk.js +23 -18
- package/svelte/openlayers-controller.d.ts +1 -1
- package/svelte/openlayers-controller.js +4 -1
- package/svelte/openlayers.d.ts +21 -0
- package/svelte/openlayers.js +30 -45
- package/svelte/react.d.ts +4 -4
- package/svelte/types.d.ts +32 -12
- package/svelte/vanilla.d.ts +14 -1
- package/svelte/vanilla.js +31 -8
- package/types.d.ts +32 -12
- package/vanilla.d.ts +14 -1
- package/vanilla.js +849 -804
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
- package/maplibregl.d.ts +0 -16
- package/maptilersdk.d.ts +0 -11
- package/svelte/maplibregl.d.ts +0 -16
- package/svelte/maptilersdk.d.ts +0 -11
|
@@ -2,8 +2,7 @@ import { feature, featureCollection } from "@turf/helpers";
|
|
|
2
2
|
import union from "@turf/union";
|
|
3
3
|
import MarkerIcon from "./MarkerIcon.svelte";
|
|
4
4
|
import { setMask } from "./mask";
|
|
5
|
-
const
|
|
6
|
-
export function createMapLibreGlMapController(map, maplibregl, marker = true, showResultMarkers = true, flyToOptions = {}, fitBoundsOptions = {}, fullGeometryStyle = {
|
|
5
|
+
const defaultGeometryStyle = {
|
|
7
6
|
fill: {
|
|
8
7
|
paint: {
|
|
9
8
|
"fill-color": "#000",
|
|
@@ -22,50 +21,70 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
22
21
|
},
|
|
23
22
|
filter: ["!", ["has", "isMask"]],
|
|
24
23
|
},
|
|
25
|
-
}
|
|
24
|
+
};
|
|
25
|
+
const RESULT_SOURCE = "mtlr-gc-full-geom";
|
|
26
|
+
const RESULT_LAYER_FILL = "mtlr-gc-full-geom-fill";
|
|
27
|
+
const RESULT_LAYER_LINE = "mtlr-gc-full-geom-line";
|
|
28
|
+
export function createMapLibreGlMapController(map, maplibregl, marker = true, showResultMarkers = true, flyToOptions = {}, fitBoundsOptions = {}, fullGeometryStyle = defaultGeometryStyle, showPolyMarker = false) {
|
|
26
29
|
let eventHandler;
|
|
27
30
|
const markers = [];
|
|
28
31
|
let selectedMarker;
|
|
29
32
|
let reverseMarker;
|
|
30
33
|
let savedData; // used to restore features on style switch
|
|
31
|
-
function
|
|
32
|
-
if (!map.
|
|
33
|
-
(
|
|
34
|
-
|
|
34
|
+
function syncFullGeometryLayer() {
|
|
35
|
+
if (!map.loaded) {
|
|
36
|
+
map.once("load", syncFullGeometryLayer);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const effFullGeometryStyle = !fullGeometryStyle
|
|
40
|
+
? undefined
|
|
41
|
+
: fullGeometryStyle === true
|
|
42
|
+
? defaultGeometryStyle
|
|
43
|
+
: fullGeometryStyle;
|
|
44
|
+
if (!effFullGeometryStyle?.fill && !effFullGeometryStyle?.line) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const source = map.getSource(RESULT_SOURCE);
|
|
48
|
+
if (source) {
|
|
49
|
+
source.setData(savedData ?? featureCollection([]));
|
|
50
|
+
}
|
|
51
|
+
else if (savedData) {
|
|
52
|
+
map.addSource(RESULT_SOURCE, {
|
|
35
53
|
type: "geojson",
|
|
36
|
-
data:
|
|
54
|
+
data: savedData,
|
|
37
55
|
});
|
|
38
56
|
}
|
|
39
|
-
|
|
57
|
+
else {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!map.getLayer(RESULT_LAYER_FILL) && effFullGeometryStyle?.fill) {
|
|
40
61
|
map.addLayer({
|
|
41
|
-
...
|
|
42
|
-
id:
|
|
62
|
+
...effFullGeometryStyle?.fill,
|
|
63
|
+
id: RESULT_LAYER_FILL,
|
|
43
64
|
type: "fill",
|
|
44
|
-
source:
|
|
65
|
+
source: RESULT_SOURCE,
|
|
45
66
|
});
|
|
46
67
|
}
|
|
47
|
-
if (!map.getLayer(
|
|
68
|
+
if (!map.getLayer(RESULT_LAYER_LINE) && effFullGeometryStyle?.line) {
|
|
48
69
|
map.addLayer({
|
|
49
|
-
...
|
|
50
|
-
id:
|
|
70
|
+
...effFullGeometryStyle?.line,
|
|
71
|
+
id: RESULT_LAYER_LINE,
|
|
51
72
|
type: "line",
|
|
52
|
-
source:
|
|
73
|
+
source: RESULT_SOURCE,
|
|
53
74
|
});
|
|
54
75
|
}
|
|
55
|
-
if (savedData) {
|
|
56
|
-
setData(savedData);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (map.loaded()) {
|
|
60
|
-
addFullGeometryLayer();
|
|
61
76
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
77
|
+
function setAndSaveData(data) {
|
|
78
|
+
savedData = data;
|
|
79
|
+
syncFullGeometryLayer();
|
|
66
80
|
}
|
|
67
81
|
map.on("styledata", () => {
|
|
68
|
-
|
|
82
|
+
// timeout prevents collision with svelte-maplibre library
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
if (savedData) {
|
|
85
|
+
syncFullGeometryLayer();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
69
88
|
});
|
|
70
89
|
const handleMapClick = (e) => {
|
|
71
90
|
eventHandler?.({
|
|
@@ -87,13 +106,6 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
87
106
|
});
|
|
88
107
|
return new maplibregl.Marker({ element, offset: [1, -13] });
|
|
89
108
|
}
|
|
90
|
-
function setData(data) {
|
|
91
|
-
savedData = data;
|
|
92
|
-
if (!data) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
map.getSource("full-geom")?.setData(data);
|
|
96
|
-
}
|
|
97
109
|
return {
|
|
98
110
|
setEventHandler(handler) {
|
|
99
111
|
if (handler) {
|
|
@@ -131,23 +143,25 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
else if (coordinates) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
if (marker instanceof Function) {
|
|
147
|
+
reverseMarker = marker(map) ?? undefined;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
reverseMarker = (typeof marker === "object"
|
|
151
|
+
? new maplibregl.Marker(marker)
|
|
152
|
+
: createMarker())
|
|
153
|
+
.setLngLat(coordinates)
|
|
154
|
+
.addTo(map);
|
|
155
|
+
reverseMarker.getElement().classList.add("marker-reverse");
|
|
156
|
+
}
|
|
140
157
|
}
|
|
141
158
|
},
|
|
142
159
|
setMarkers(markedFeatures, picked) {
|
|
143
|
-
if (!marker) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
160
|
for (const marker of markers) {
|
|
147
161
|
marker.remove();
|
|
148
162
|
}
|
|
149
163
|
markers.length = 0;
|
|
150
|
-
|
|
164
|
+
setAndSaveData(undefined);
|
|
151
165
|
if (!maplibregl) {
|
|
152
166
|
return;
|
|
153
167
|
}
|
|
@@ -163,14 +177,14 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
163
177
|
setMask({
|
|
164
178
|
...picked,
|
|
165
179
|
geometry: unioned.geometry,
|
|
166
|
-
},
|
|
180
|
+
}, setAndSaveData);
|
|
167
181
|
handled = true;
|
|
168
182
|
}
|
|
169
183
|
else {
|
|
170
184
|
const geometries = picked.geometry.geometries.filter((geometry) => geometry.type === "LineString" ||
|
|
171
185
|
geometry.type === "MultiLineString");
|
|
172
186
|
if (geometries.length > 0) {
|
|
173
|
-
|
|
187
|
+
setAndSaveData({
|
|
174
188
|
...picked,
|
|
175
189
|
geometry: { type: "GeometryCollection", geometries },
|
|
176
190
|
});
|
|
@@ -183,19 +197,26 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
183
197
|
}
|
|
184
198
|
else if (picked.geometry.type === "Polygon" ||
|
|
185
199
|
picked.geometry.type === "MultiPolygon") {
|
|
186
|
-
setMask(picked,
|
|
200
|
+
setMask(picked, setAndSaveData);
|
|
187
201
|
}
|
|
188
202
|
else if (picked.geometry.type === "LineString" ||
|
|
189
203
|
picked.geometry.type === "MultiLineString") {
|
|
190
|
-
|
|
204
|
+
setAndSaveData(picked);
|
|
191
205
|
return; // no pin for (multi)linestrings
|
|
192
206
|
}
|
|
193
|
-
if (
|
|
194
|
-
|
|
207
|
+
if (!showPolyMarker && picked.geometry.type !== "Point") {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (marker instanceof Function) {
|
|
211
|
+
const m = marker(map, picked);
|
|
212
|
+
if (m) {
|
|
213
|
+
markers.push(m);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else if (marker) {
|
|
217
|
+
markers.push(typeof marker === "object"
|
|
195
218
|
? new maplibregl.Marker(marker)
|
|
196
|
-
: createMarker())
|
|
197
|
-
.setLngLat(picked.center)
|
|
198
|
-
.addTo(map));
|
|
219
|
+
: createMarker().setLngLat(picked.center).addTo(map));
|
|
199
220
|
}
|
|
200
221
|
}
|
|
201
222
|
if (showResultMarkers) {
|
|
@@ -203,19 +224,28 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
203
224
|
if (feature === picked) {
|
|
204
225
|
continue;
|
|
205
226
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
let marker;
|
|
228
|
+
if (showResultMarkers instanceof Function) {
|
|
229
|
+
marker = showResultMarkers(map, feature);
|
|
230
|
+
if (!marker) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
marker = (typeof showResultMarkers === "object"
|
|
236
|
+
? new maplibregl.Marker(showResultMarkers)
|
|
237
|
+
: createMarker(true))
|
|
238
|
+
.setLngLat(feature.center)
|
|
239
|
+
.setPopup(new maplibregl.Popup({
|
|
240
|
+
offset: [1, -27],
|
|
241
|
+
closeButton: false,
|
|
242
|
+
closeOnMove: true,
|
|
243
|
+
className: "maptiler-gc-popup",
|
|
244
|
+
}).setText(feature.place_type[0] === "reverse"
|
|
245
|
+
? feature.place_name
|
|
246
|
+
: feature.place_name.replace(/,.*/, "")))
|
|
247
|
+
.addTo(map);
|
|
248
|
+
}
|
|
219
249
|
const element = marker.getElement();
|
|
220
250
|
element.addEventListener("click", (e) => {
|
|
221
251
|
e.stopPropagation();
|
package/svelte/maplibregl.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as maplibregl from "maplibre-gl";
|
|
2
|
-
import {
|
|
2
|
+
import { crateClasses, } from "./MapLibreBasedGeocodingControl";
|
|
3
3
|
export { createMapLibreGlMapController } from "./maplibregl-controller";
|
|
4
|
+
const { MapLibreBasedGeocodingControl, events } = crateClasses(maplibregl.Evented, maplibregl);
|
|
4
5
|
export class GeocodingControl extends MapLibreBasedGeocodingControl {
|
|
5
|
-
getMapLibreGl() {
|
|
6
|
-
return maplibregl;
|
|
7
|
-
}
|
|
8
6
|
onAdd(map) {
|
|
9
7
|
return super.onAddInt(map);
|
|
10
8
|
}
|
|
11
|
-
getExtraProps() {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
9
|
}
|
|
10
|
+
export const SelectEvent = events.SelectEvent;
|
|
11
|
+
export const FeaturesListedEvent = events.FeaturesListedEvent;
|
|
12
|
+
export const FeaturesMarkedEvent = events.FeaturesMarkedEvent;
|
|
13
|
+
export const OptionsVisibilityChangeEvent = events.OptionsVisibilityChangeEvent;
|
|
14
|
+
export const PickEvent = events.PickEvent;
|
|
15
|
+
export const QueryChangeEvent = events.QueryChangeEvent;
|
|
16
|
+
export const ResponseEvent = events.ResponseEvent;
|
|
17
|
+
export const ReverseToggleEvent = events.ReverseToggleEvent;
|
package/svelte/maptilersdk.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import * as maptilersdk from "@maptiler/sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { crateClasses, } from "./MapLibreBasedGeocodingControl";
|
|
3
3
|
export { createMapLibreGlMapController } from "./maplibregl-controller";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { MapLibreBasedGeocodingControl, events } = crateClasses(maptilersdk.Evented, maptilersdk, (map, div) => {
|
|
5
|
+
const sdkConfig = {};
|
|
6
|
+
if (!("getSdkConfig" in map && typeof map.getSdkConfig === "function")) {
|
|
7
|
+
throw new Error("MapTiler SDK not detected");
|
|
8
|
+
}
|
|
9
|
+
const { primaryLanguage, apiKey } = map.getSdkConfig();
|
|
10
|
+
sdkConfig.apiKey = apiKey;
|
|
11
|
+
const match = /^([a-z]{2})($|_|-)/.exec(primaryLanguage);
|
|
12
|
+
if (match) {
|
|
13
|
+
sdkConfig.language = match[1];
|
|
7
14
|
}
|
|
15
|
+
div.className += " maptiler-ctrl";
|
|
16
|
+
return sdkConfig;
|
|
17
|
+
});
|
|
18
|
+
export class GeocodingControl extends MapLibreBasedGeocodingControl {
|
|
8
19
|
onAdd(map) {
|
|
9
20
|
return super.onAddInt(map);
|
|
10
21
|
}
|
|
11
|
-
getExtraProps(map, div) {
|
|
12
|
-
const sdkConfig = {};
|
|
13
|
-
if (!("getSdkConfig" in map && typeof map.getSdkConfig === "function")) {
|
|
14
|
-
throw new Error("MapTiler SDK not detected");
|
|
15
|
-
}
|
|
16
|
-
const { primaryLanguage, apiKey } = map.getSdkConfig();
|
|
17
|
-
sdkConfig.apiKey = apiKey;
|
|
18
|
-
const match = /^([a-z]{2})($|_|-)/.exec(primaryLanguage);
|
|
19
|
-
if (match) {
|
|
20
|
-
sdkConfig.language = match[1];
|
|
21
|
-
}
|
|
22
|
-
div.className += " maptiler-ctrl";
|
|
23
|
-
return sdkConfig;
|
|
24
|
-
}
|
|
25
22
|
}
|
|
23
|
+
export const SelectEvent = events.SelectEvent;
|
|
24
|
+
export const FeaturesListedEvent = events.FeaturesListedEvent;
|
|
25
|
+
export const FeaturesMarkedEvent = events.FeaturesMarkedEvent;
|
|
26
|
+
export const OptionsVisibilityChangeEvent = events.OptionsVisibilityChangeEvent;
|
|
27
|
+
export const PickEvent = events.PickEvent;
|
|
28
|
+
export const QueryChangeEvent = events.QueryChangeEvent;
|
|
29
|
+
export const ResponseEvent = events.ResponseEvent;
|
|
30
|
+
export const ReverseToggleEvent = events.ReverseToggleEvent;
|
|
@@ -3,7 +3,7 @@ import type { AnimationOptions, FitOptions } from "ol/View";
|
|
|
3
3
|
import { type StyleLike } from "ol/style/Style";
|
|
4
4
|
import type { FlatStyleLike } from "ol/style/flat";
|
|
5
5
|
import type { BBox, Feature as FeatureType, MapEvent, Position } from "./types";
|
|
6
|
-
export declare function createOpenLayersMapController(map: Map, flyToOptions?: AnimationOptions, flyToBounds?: FitOptions, fullGeometryStyle?: StyleLike | FlatStyleLike): {
|
|
6
|
+
export declare function createOpenLayersMapController(map: Map, flyToOptions?: AnimationOptions, flyToBounds?: FitOptions, fullGeometryStyle?: StyleLike | FlatStyleLike, showPolyMarker?: boolean): {
|
|
7
7
|
setEventHandler(handler: undefined | ((e: MapEvent) => void)): void;
|
|
8
8
|
flyTo(center: Position, zoom: number): void;
|
|
9
9
|
fitBounds(bbox: BBox, padding: number, maxZoom: number): void;
|
|
@@ -57,7 +57,7 @@ function defaultStyle(feature) {
|
|
|
57
57
|
: undefined,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
export function createOpenLayersMapController(map, flyToOptions = {}, flyToBounds = {}, fullGeometryStyle = defaultStyle) {
|
|
60
|
+
export function createOpenLayersMapController(map, flyToOptions = {}, flyToBounds = {}, fullGeometryStyle = defaultStyle, showPolyMarker = false) {
|
|
61
61
|
let prevSelected = -1;
|
|
62
62
|
let prevHovered;
|
|
63
63
|
let eventHandler;
|
|
@@ -235,6 +235,9 @@ export function createOpenLayersMapController(map, flyToOptions = {}, flyToBound
|
|
|
235
235
|
source.addFeature(new OlFeature(fromWgs84(new OlMultiLineString(picked.geometry.coordinates))));
|
|
236
236
|
return; // no pin for (multi)linestrings
|
|
237
237
|
}
|
|
238
|
+
if (!showPolyMarker && picked.geometry.type !== "Point") {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
238
241
|
source.addFeature(new OlFeature(fromWgs84(new OlPoint(picked.center))));
|
|
239
242
|
}
|
|
240
243
|
for (const feature of markedFeatures ?? []) {
|
package/svelte/openlayers.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Map } from "ol";
|
|
2
|
+
import type { ObjectEvent } from "ol/Object";
|
|
3
|
+
import type { CombinedOnSignature, EventTypes } from "ol/Observable";
|
|
2
4
|
import type { AnimationOptions, FitOptions } from "ol/View";
|
|
3
5
|
import { Control } from "ol/control";
|
|
4
6
|
import type { Options } from "ol/control/Control";
|
|
7
|
+
import type { EventsKey } from "ol/events";
|
|
5
8
|
import BaseEvent from "ol/events/Event";
|
|
6
9
|
import type { StyleLike } from "ol/style/Style";
|
|
7
10
|
import type { FlatStyleLike } from "ol/style/flat";
|
|
@@ -11,8 +14,26 @@ type OpenLayersControlOptions = ControlOptions & Options & {
|
|
|
11
14
|
flyTo?: boolean | (AnimationOptions & FitOptions);
|
|
12
15
|
fullGeometryStyle?: StyleLike | FlatStyleLike;
|
|
13
16
|
};
|
|
17
|
+
type CustomEventMap = {
|
|
18
|
+
select: SelectEvent;
|
|
19
|
+
featureslisted: FeaturesListedEvent;
|
|
20
|
+
featuresmarked: FeaturesMarkedEvent;
|
|
21
|
+
optionsvisibilitychange: OptionsVisibilityChangeEvent;
|
|
22
|
+
pick: PickEvent;
|
|
23
|
+
querychange: QueryChangeEvent;
|
|
24
|
+
response: ResponseEvent;
|
|
25
|
+
reversetoggle: ReverseToggleEvent;
|
|
26
|
+
};
|
|
27
|
+
type CustomObjectOnSignature<ReturnType> = {
|
|
28
|
+
<K extends keyof CustomEventMap>(type: K, listener: (evt: CustomEventMap[K]) => void): ReturnType;
|
|
29
|
+
} & {
|
|
30
|
+
(type: "propertychange", listener: (evt: ObjectEvent) => void): ReturnType;
|
|
31
|
+
} & CombinedOnSignature<EventTypes | "propertychange" | keyof CustomEventMap, ReturnType>;
|
|
14
32
|
export declare class GeocodingControl extends Control {
|
|
15
33
|
#private;
|
|
34
|
+
on: CustomObjectOnSignature<EventsKey>;
|
|
35
|
+
once: CustomObjectOnSignature<EventsKey>;
|
|
36
|
+
un: CustomObjectOnSignature<EventsKey>;
|
|
16
37
|
constructor(options: OpenLayersControlOptions);
|
|
17
38
|
setMap(map: Map | null): void;
|
|
18
39
|
setOptions(options: OpenLayersControlOptions): void;
|
package/svelte/openlayers.js
CHANGED
|
@@ -21,45 +21,30 @@ export class GeocodingControl extends Control {
|
|
|
21
21
|
...restOptions,
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
case "pick":
|
|
49
|
-
this.dispatchEvent(new PickEvent(event.detail));
|
|
50
|
-
break;
|
|
51
|
-
case "queryChange":
|
|
52
|
-
this.dispatchEvent(new QueryChangeEvent(event.detail));
|
|
53
|
-
break;
|
|
54
|
-
case "response":
|
|
55
|
-
this.dispatchEvent(new ResponseEvent(event.detail.url, event.detail.featureCollection));
|
|
56
|
-
break;
|
|
57
|
-
case "reverseToggle":
|
|
58
|
-
this.dispatchEvent(new ReverseToggleEvent(event.detail));
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
24
|
+
this.#gc.$on("select", (event) => {
|
|
25
|
+
this.dispatchEvent(new SelectEvent(event.detail.feature));
|
|
26
|
+
});
|
|
27
|
+
this.#gc.$on("pick", (event) => {
|
|
28
|
+
this.dispatchEvent(new PickEvent(event.detail.feature));
|
|
29
|
+
});
|
|
30
|
+
this.#gc.$on("featureslisted", (event) => {
|
|
31
|
+
this.dispatchEvent(new FeaturesListedEvent(event.detail.features));
|
|
32
|
+
});
|
|
33
|
+
this.#gc.$on("featuresmarked", (event) => {
|
|
34
|
+
this.dispatchEvent(new FeaturesMarkedEvent(event.detail.features));
|
|
35
|
+
});
|
|
36
|
+
this.#gc.$on("response", (event) => {
|
|
37
|
+
this.dispatchEvent(new ResponseEvent(event.detail.url, event.detail.featureCollection));
|
|
38
|
+
});
|
|
39
|
+
this.#gc.$on("optionsvisibilitychange", (event) => {
|
|
40
|
+
this.dispatchEvent(new OptionsVisibilityChangeEvent(event.detail.optionsVisible));
|
|
41
|
+
});
|
|
42
|
+
this.#gc.$on("reversetoggle", (event) => {
|
|
43
|
+
this.dispatchEvent(new ReverseToggleEvent(event.detail.reverse));
|
|
44
|
+
});
|
|
45
|
+
this.#gc.$on("querychange", (event) => {
|
|
46
|
+
this.dispatchEvent(new QueryChangeEvent(event.detail.query));
|
|
47
|
+
});
|
|
63
48
|
this.#options = options;
|
|
64
49
|
}
|
|
65
50
|
setMap(map) {
|
|
@@ -72,7 +57,7 @@ export class GeocodingControl extends Control {
|
|
|
72
57
|
const mapController = createOpenLayersMapController(map, typeof flyTo === "boolean" ? undefined : flyTo, typeof flyTo === "boolean" ? undefined : flyTo,
|
|
73
58
|
// marker,
|
|
74
59
|
// showResultMarkers,
|
|
75
|
-
fullGeometryStyle);
|
|
60
|
+
fullGeometryStyle, this.#options.showFullGeometry === "polygon-with-marker");
|
|
76
61
|
this.#gc?.$set({ mapController });
|
|
77
62
|
}
|
|
78
63
|
}
|
|
@@ -110,21 +95,21 @@ export class SelectEvent extends BaseEvent {
|
|
|
110
95
|
export class FeaturesListedEvent extends BaseEvent {
|
|
111
96
|
features;
|
|
112
97
|
constructor(features) {
|
|
113
|
-
super("
|
|
98
|
+
super("featureslisted");
|
|
114
99
|
this.features = features;
|
|
115
100
|
}
|
|
116
101
|
}
|
|
117
102
|
export class FeaturesMarkedEvent extends BaseEvent {
|
|
118
103
|
features;
|
|
119
104
|
constructor(features) {
|
|
120
|
-
super("
|
|
105
|
+
super("featuresmarked");
|
|
121
106
|
this.features = features;
|
|
122
107
|
}
|
|
123
108
|
}
|
|
124
109
|
export class OptionsVisibilityChangeEvent extends BaseEvent {
|
|
125
110
|
optionsVisible;
|
|
126
111
|
constructor(optionsVisible) {
|
|
127
|
-
super("
|
|
112
|
+
super("optionsvisibilitychange");
|
|
128
113
|
this.optionsVisible = optionsVisible;
|
|
129
114
|
}
|
|
130
115
|
}
|
|
@@ -138,7 +123,7 @@ export class PickEvent extends BaseEvent {
|
|
|
138
123
|
export class QueryChangeEvent extends BaseEvent {
|
|
139
124
|
query;
|
|
140
125
|
constructor(query) {
|
|
141
|
-
super("
|
|
126
|
+
super("querychange");
|
|
142
127
|
this.query = query;
|
|
143
128
|
}
|
|
144
129
|
}
|
|
@@ -154,7 +139,7 @@ export class ResponseEvent extends BaseEvent {
|
|
|
154
139
|
export class ReverseToggleEvent extends BaseEvent {
|
|
155
140
|
reverse;
|
|
156
141
|
constructor(reverse) {
|
|
157
|
-
super("
|
|
142
|
+
super("reversetoggle");
|
|
158
143
|
this.reverse = reverse;
|
|
159
144
|
}
|
|
160
145
|
}
|
package/svelte/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ControlOptions,
|
|
2
|
-
type EventNames = keyof
|
|
1
|
+
import type { ControlOptions, DispatcherTypeCC, MapController } from "./types";
|
|
2
|
+
type EventNames = keyof DispatcherTypeCC;
|
|
3
3
|
type EventHandlerFnName<T extends EventNames> = `on${Capitalize<T>}`;
|
|
4
4
|
type CallbackProperties<T> = {
|
|
5
5
|
[K in keyof T as EventHandlerFnName<Extract<K, EventNames>>]?: (event: T[K]) => void;
|
|
@@ -7,7 +7,7 @@ type CallbackProperties<T> = {
|
|
|
7
7
|
type MapControllerProp = {
|
|
8
8
|
mapController?: MapController;
|
|
9
9
|
};
|
|
10
|
-
export type Props = ControlOptions & CallbackProperties<
|
|
10
|
+
export type Props = ControlOptions & CallbackProperties<DispatcherTypeCC> & MapControllerProp;
|
|
11
11
|
export type Methods = {
|
|
12
12
|
blur(): void;
|
|
13
13
|
focus(): void;
|
|
@@ -15,5 +15,5 @@ export type Methods = {
|
|
|
15
15
|
clearMap(): void;
|
|
16
16
|
clearList(): void;
|
|
17
17
|
};
|
|
18
|
-
declare const ReactGeocodingControl: import("react").ForwardRefExoticComponent<ControlOptions & CallbackProperties<
|
|
18
|
+
declare const ReactGeocodingControl: import("react").ForwardRefExoticComponent<ControlOptions & CallbackProperties<DispatcherTypeCC> & MapControllerProp & import("react").RefAttributes<Methods>>;
|
|
19
19
|
export { ReactGeocodingControl as GeocodingControl };
|
package/svelte/types.d.ts
CHANGED
|
@@ -123,6 +123,7 @@ export type ControlOptions = {
|
|
|
123
123
|
* Default value is `false`.
|
|
124
124
|
*/
|
|
125
125
|
showResultsWhileTyping?: boolean;
|
|
126
|
+
autocompleteTimeout?: number;
|
|
126
127
|
/**
|
|
127
128
|
* Set to `false` to disable fuzzy search.
|
|
128
129
|
* Default value is `true`
|
|
@@ -188,15 +189,16 @@ export type ControlOptions = {
|
|
|
188
189
|
clearButtonTitle?: string;
|
|
189
190
|
/**
|
|
190
191
|
* Set to `false` to hide place/POI type. If set to `"always"` then type is shown for all items.
|
|
191
|
-
* If set to `"ifNeeded"` then type is shown only for places/POIs not determined from the icon.
|
|
192
|
-
* Default value is `"
|
|
192
|
+
* If set to `"if-needed"` (deprecated `"ifNeeded"`) then type is shown only for places/POIs not determined from the icon.
|
|
193
|
+
* Default value is `"if-needed"`.
|
|
193
194
|
*/
|
|
194
|
-
showPlaceType?: false | "always" | "ifNeeded";
|
|
195
|
+
showPlaceType?: false | "always" | "ifNeeded" | "if-needed";
|
|
195
196
|
/**
|
|
196
197
|
* Set to `true` to show full feature geometry of the chosen result. Otherwise only marker will be shown.
|
|
198
|
+
* If `"polygon-with-marker"` is specified, then also a marker will be shown in the hotspot or center of polygon features.
|
|
197
199
|
* Default value is `true`.
|
|
198
200
|
*/
|
|
199
|
-
showFullGeometry?: boolean;
|
|
201
|
+
showFullGeometry?: boolean | "polygon-with-marker";
|
|
200
202
|
/**
|
|
201
203
|
* Limit search to specified country(ies).
|
|
202
204
|
* Default value is `undefined` - use all countries.
|
|
@@ -257,16 +259,34 @@ export type ControlOptions = {
|
|
|
257
259
|
*/
|
|
258
260
|
markerOnSelected?: boolean;
|
|
259
261
|
};
|
|
260
|
-
export type
|
|
261
|
-
featuresListed:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
export type DispatcherTypeCC = {
|
|
263
|
+
featuresListed: {
|
|
264
|
+
features: Feature[] | undefined;
|
|
265
|
+
};
|
|
266
|
+
featuresMarked: {
|
|
267
|
+
features: Feature[] | undefined;
|
|
268
|
+
};
|
|
269
|
+
optionsVisibilityChange: {
|
|
270
|
+
optionsVisible: boolean;
|
|
271
|
+
};
|
|
272
|
+
pick: {
|
|
273
|
+
feature: Feature | undefined;
|
|
274
|
+
};
|
|
275
|
+
queryChange: {
|
|
276
|
+
query: string;
|
|
277
|
+
};
|
|
266
278
|
response: {
|
|
267
279
|
url: string;
|
|
268
280
|
featureCollection: FeatureCollection;
|
|
269
281
|
};
|
|
270
|
-
reverseToggle:
|
|
271
|
-
|
|
282
|
+
reverseToggle: {
|
|
283
|
+
reverse: boolean;
|
|
284
|
+
};
|
|
285
|
+
select: {
|
|
286
|
+
feature: Feature | undefined;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export type DispatcherType = {
|
|
290
|
+
[T in keyof DispatcherTypeCC as Lowercase<T>]: DispatcherTypeCC[T];
|
|
272
291
|
};
|
|
292
|
+
export type EnsureMatchingKeys<T, U> = keyof T extends keyof U ? keyof U extends keyof T ? true : never : never;
|
package/svelte/vanilla.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import type { ControlOptions, MapController } from "./types";
|
|
1
|
+
import type { ControlOptions, DispatcherType, MapController } from "./types";
|
|
2
2
|
type Options = ControlOptions & {
|
|
3
3
|
mapController?: MapController;
|
|
4
4
|
};
|
|
5
|
+
interface GeocodingControlEvent<T> extends CustomEvent<T> {
|
|
6
|
+
readonly target: GeocodingControl;
|
|
7
|
+
readonly currentTarget: GeocodingControl;
|
|
8
|
+
}
|
|
9
|
+
type CustomEventListenerOrEventListenerObject<K extends keyof CustomEventMap> = ((evt: CustomEventMap[K]) => void) | {
|
|
10
|
+
handleEvent(object: CustomEventMap[K]): void;
|
|
11
|
+
};
|
|
12
|
+
type CustomEventMap = {
|
|
13
|
+
[T in keyof DispatcherType]: GeocodingControlEvent<DispatcherType[T]>;
|
|
14
|
+
};
|
|
5
15
|
export declare class GeocodingControl extends EventTarget {
|
|
6
16
|
#private;
|
|
7
17
|
constructor({ target, ...options }: Options & {
|
|
@@ -13,5 +23,8 @@ export declare class GeocodingControl extends EventTarget {
|
|
|
13
23
|
clearList(): void;
|
|
14
24
|
focus(): void;
|
|
15
25
|
blur(): void;
|
|
26
|
+
addEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: AddEventListenerOptions | boolean): void;
|
|
27
|
+
removeEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: EventListenerOptions | boolean): void;
|
|
28
|
+
dispatchEvent<K extends keyof CustomEventMap>(event: CustomEventMap[K]): boolean;
|
|
16
29
|
}
|
|
17
30
|
export {};
|