@maptiler/geocoding-control 2.0.0 → 2.0.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 +2616 -27
- package/leaflet-controller.d.ts +1 -1
- package/leaflet-controller.js +97 -95
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +2 -2
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.d.ts +26 -4
- package/leaflet.js +906 -909
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +3 -3
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.d.ts +1 -1
- package/maplibregl-controller.js +480 -466
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +3 -3
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.d.ts +2594 -9
- package/maplibregl.js +2094 -1969
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.d.ts +2594 -9
- package/maptilersdk.js +2086 -1964
- 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 +62 -60
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +2 -2
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.d.ts +21 -0
- package/openlayers.js +754 -786
- 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 +619 -619
- 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 +1 -1
- package/svelte/FeatureItem.svelte.d.ts +2 -2
- package/svelte/GeocodingControl.svelte +31 -32
- package/svelte/GeocodingControl.svelte.d.ts +26 -13
- package/svelte/MapLibreBasedGeocodingControl.d.ts +2616 -27
- package/svelte/MapLibreBasedGeocodingControl.js +120 -17
- package/svelte/leaflet-controller.d.ts +1 -1
- package/svelte/leaflet-controller.js +4 -1
- package/svelte/leaflet.d.ts +26 -4
- package/svelte/leaflet.js +17 -19
- package/svelte/maplibregl-controller.d.ts +1 -1
- package/svelte/maplibregl-controller.js +45 -36
- package/svelte/maplibregl.d.ts +2594 -9
- package/svelte/maplibregl.js +11 -3
- package/svelte/maptilersdk.d.ts +2594 -9
- package/svelte/maptilersdk.js +11 -3
- 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/react.js +5 -5
- package/svelte/types.d.ts +84 -35
- package/svelte/vanilla.d.ts +14 -1
- package/svelte/vanilla.js +31 -8
- package/types.d.ts +84 -35
- package/vanilla.d.ts +14 -1
- package/vanilla.js +929 -901
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
package/svelte/maptilersdk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as maptilersdk from "@maptiler/sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { crateClasses, } from "./MapLibreBasedGeocodingControl";
|
|
3
3
|
export { createMapLibreGlMapController } from "./maplibregl-controller";
|
|
4
|
-
const
|
|
4
|
+
const { MapLibreBasedGeocodingControl, events } = crateClasses(maptilersdk.Evented, maptilersdk, (map, div) => {
|
|
5
5
|
const sdkConfig = {};
|
|
6
6
|
if (!("getSdkConfig" in map && typeof map.getSdkConfig === "function")) {
|
|
7
7
|
throw new Error("MapTiler SDK not detected");
|
|
@@ -15,8 +15,16 @@ const Base = crateBaseClass(maptilersdk.Evented, maptilersdk, (map, div) => {
|
|
|
15
15
|
div.className += " maptiler-ctrl";
|
|
16
16
|
return sdkConfig;
|
|
17
17
|
});
|
|
18
|
-
export class GeocodingControl extends
|
|
18
|
+
export class GeocodingControl extends MapLibreBasedGeocodingControl {
|
|
19
19
|
onAdd(map) {
|
|
20
20
|
return super.onAddInt(map);
|
|
21
21
|
}
|
|
22
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;
|
|
@@ -9,7 +9,7 @@ export declare function createOpenLayersMapController(map: Map, flyToOptions?: A
|
|
|
9
9
|
fitBounds(bbox: BBox, padding: number, maxZoom: number): void;
|
|
10
10
|
indicateReverse(reverse: boolean): void;
|
|
11
11
|
setReverseMarker(coordinates?: Position): void;
|
|
12
|
-
|
|
12
|
+
setFeatures(markedFeatures: FeatureType[] | undefined, picked: FeatureType | undefined, showPolygonMarker: boolean): void;
|
|
13
13
|
setSelectedMarker(index: number): void;
|
|
14
14
|
getCenterAndZoom(): [number, x: number, y: number] | undefined;
|
|
15
15
|
};
|
|
@@ -167,7 +167,7 @@ export function createOpenLayersMapController(map, flyToOptions = {}, flyToBound
|
|
|
167
167
|
source.addFeature(reverseMarker);
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
|
-
|
|
170
|
+
setFeatures(markedFeatures, picked, showPolygonMarker) {
|
|
171
171
|
function setData(data) {
|
|
172
172
|
if (!data) {
|
|
173
173
|
return;
|
|
@@ -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 (!showPolygonMarker && 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) {
|
|
@@ -77,7 +62,7 @@ export class GeocodingControl extends Control {
|
|
|
77
62
|
}
|
|
78
63
|
}
|
|
79
64
|
setOptions(options) {
|
|
80
|
-
this.#options
|
|
65
|
+
Object.assign(this.#options, options);
|
|
81
66
|
const { flyTo, fullGeometryStyle, ...restOptions } = this.#options;
|
|
82
67
|
this.#gc?.$set({
|
|
83
68
|
...restOptions,
|
|
@@ -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/react.js
CHANGED
|
@@ -11,6 +11,7 @@ const eventNames = [
|
|
|
11
11
|
"select",
|
|
12
12
|
];
|
|
13
13
|
const propertyNames = [
|
|
14
|
+
"adjustUrlQuery",
|
|
14
15
|
"apiKey",
|
|
15
16
|
"bbox",
|
|
16
17
|
"clearButtonTitle",
|
|
@@ -19,25 +20,24 @@ const propertyNames = [
|
|
|
19
20
|
"country",
|
|
20
21
|
"debounceSearch",
|
|
21
22
|
"enableReverse",
|
|
22
|
-
"reverseActive",
|
|
23
23
|
"errorMessage",
|
|
24
|
+
"excludeTypes",
|
|
24
25
|
"filter",
|
|
25
26
|
"fuzzyMatch",
|
|
26
27
|
"language",
|
|
27
28
|
"limit",
|
|
29
|
+
"mapController",
|
|
28
30
|
"minLength",
|
|
29
31
|
"noResultsMessage",
|
|
32
|
+
"pickedResultStyle",
|
|
30
33
|
"placeholder",
|
|
31
34
|
"proximity",
|
|
35
|
+
"reverseActive",
|
|
32
36
|
"reverseButtonTitle",
|
|
33
|
-
"showFullGeometry",
|
|
34
37
|
"showPlaceType",
|
|
35
38
|
"showResultsWhileTyping",
|
|
36
|
-
"adjustUrlQuery",
|
|
37
39
|
"types",
|
|
38
|
-
"excludeTypes",
|
|
39
40
|
"zoom",
|
|
40
|
-
"mapController",
|
|
41
41
|
];
|
|
42
42
|
function getEventFnName(name) {
|
|
43
43
|
return ("on" +
|
package/svelte/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type MapController = {
|
|
|
33
33
|
flyTo(center: Position, zoom?: number): void;
|
|
34
34
|
fitBounds(bbox: BBox, padding: number, maxZoom?: number): void;
|
|
35
35
|
indicateReverse(reverse: boolean): void;
|
|
36
|
-
|
|
36
|
+
setFeatures(features: Feature[] | undefined, picked: Feature | undefined, showPolygonMarker: boolean): void;
|
|
37
37
|
setReverseMarker(coordinates?: Position): void;
|
|
38
38
|
setSelectedMarker(index: number): void;
|
|
39
39
|
getCenterAndZoom(): [zoom: number, lon: number, lat: number] | undefined;
|
|
@@ -68,43 +68,51 @@ export type ControlOptions = {
|
|
|
68
68
|
/**
|
|
69
69
|
* Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box.
|
|
70
70
|
* This parameter may be useful for reducing the total number of API calls made for a single query.
|
|
71
|
+
*
|
|
71
72
|
* Default value is `200`.
|
|
72
73
|
*/
|
|
73
74
|
debounceSearch?: number;
|
|
74
75
|
/**
|
|
75
76
|
* Search results closer to the proximity point will be given higher priority. First matching rule from the array will be used.
|
|
76
77
|
* Set to `null` to disable the proximity.
|
|
78
|
+
*
|
|
77
79
|
* Default value is `[{ type: "server-geolocation" }]`.
|
|
78
80
|
*/
|
|
79
81
|
proximity?: ProximityRule[] | null;
|
|
80
82
|
/**
|
|
81
83
|
* Override the default placeholder attribute value.
|
|
84
|
+
*
|
|
82
85
|
* Default value is `"Search"`.
|
|
83
86
|
*/
|
|
84
87
|
placeholder?: string;
|
|
85
88
|
/**
|
|
86
89
|
* Override the default error message.
|
|
90
|
+
*
|
|
87
91
|
* Default value is `"Something went wrong…"`.
|
|
88
92
|
*/
|
|
89
93
|
errorMessage?: string;
|
|
90
94
|
/**
|
|
91
95
|
* Override the default message if no results are found.
|
|
96
|
+
*
|
|
92
97
|
* Default value is `"Oops! Looks like you're trying to predict something that's not quite right. We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term. Keep on typing - we'll do our best to get you where you need to go!"`.
|
|
93
98
|
*/
|
|
94
99
|
noResultsMessage?: string;
|
|
95
100
|
/**
|
|
96
101
|
* Minimum number of characters to enter before results are shown.
|
|
102
|
+
*
|
|
97
103
|
* Default value is `2`.
|
|
98
104
|
*/
|
|
99
105
|
minLength?: number;
|
|
100
106
|
/**
|
|
101
107
|
* A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY].
|
|
102
108
|
* Search results will be limited to the bounding box.
|
|
109
|
+
*
|
|
103
110
|
* Default value is `undefined`.
|
|
104
111
|
*/
|
|
105
112
|
bbox?: BBox;
|
|
106
113
|
/**
|
|
107
114
|
* Maximum number of results to show.
|
|
115
|
+
*
|
|
108
116
|
* Default value is `5`.
|
|
109
117
|
*/
|
|
110
118
|
limit?: number;
|
|
@@ -113,128 +121,144 @@ export type ControlOptions = {
|
|
|
113
121
|
* Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script.
|
|
114
122
|
* More than one value can also be specified, separated by commas.
|
|
115
123
|
* Set to `null` or empty string for disabling language-specific searching.
|
|
116
|
-
*
|
|
117
|
-
* Default value is `undefined
|
|
124
|
+
*
|
|
125
|
+
* Default value is `undefined` which means to use the browser's language settings.
|
|
118
126
|
*/
|
|
119
127
|
language?: string | string[] | null;
|
|
120
128
|
/**
|
|
121
129
|
* If `false`, indicates that search will only occur on enter key press.
|
|
122
130
|
* If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option.
|
|
131
|
+
*
|
|
123
132
|
* Default value is `false`.
|
|
124
133
|
*/
|
|
125
134
|
showResultsWhileTyping?: boolean;
|
|
126
135
|
/**
|
|
127
136
|
* Set to `false` to disable fuzzy search.
|
|
128
|
-
*
|
|
137
|
+
*
|
|
138
|
+
* Default value is `true`.
|
|
129
139
|
*/
|
|
130
140
|
fuzzyMatch?: boolean;
|
|
131
141
|
/**
|
|
132
142
|
* On geocoded result what zoom level should the map animate to when a bbox in the response isn't present or is a point.
|
|
133
143
|
* If a bbox is present and not a point then the map will fit to the bbox.
|
|
134
144
|
*
|
|
135
|
-
* Value
|
|
145
|
+
* Value is key-value pairs, where key is a <type> or <type>.<categoy> and the value is the zoom level.
|
|
136
146
|
*
|
|
137
147
|
* Default value is `GeocodingControl.ZOOM_DEFAULTS`.
|
|
138
148
|
*/
|
|
139
|
-
zoom?:
|
|
140
|
-
/**
|
|
141
|
-
* On geocoded result what max zoom level should the map animate to when a bbox in the response isn't present or is a point.
|
|
142
|
-
* Used for small features.
|
|
143
|
-
*
|
|
144
|
-
* If a bbox is present and not a point then the map will fit to the bbox.
|
|
145
|
-
*
|
|
146
|
-
* @deprecated use `zoom` option
|
|
147
|
-
*/
|
|
148
|
-
maxZoom?: number;
|
|
149
|
+
zoom?: Record<string, number>;
|
|
149
150
|
/**
|
|
150
151
|
* If `true`, the geocoder control will collapse until hovered or in focus.
|
|
152
|
+
*
|
|
151
153
|
* Default value is `false`.
|
|
152
154
|
*/
|
|
153
155
|
collapsed?: boolean;
|
|
154
156
|
/**
|
|
155
157
|
* If true, the geocoder control will clear its value when the input blurs.
|
|
158
|
+
*
|
|
156
159
|
* Default value is `false`.
|
|
157
160
|
*/
|
|
158
161
|
clearOnBlur?: boolean;
|
|
159
162
|
/**
|
|
160
163
|
* A function which accepts a Feature in the Carmen GeoJSON format to filter out results from the Geocoding API response before they are included in the suggestions list.
|
|
161
164
|
* Return true to keep the item, false otherwise.
|
|
165
|
+
*
|
|
166
|
+
* Default value is a function returning always `true`.
|
|
162
167
|
*/
|
|
163
168
|
filter?: (feature: Feature) => boolean;
|
|
164
169
|
/**
|
|
165
170
|
* Class of the root element.
|
|
171
|
+
*
|
|
166
172
|
* Default value is `undefined`.
|
|
167
173
|
*/
|
|
168
174
|
class?: string;
|
|
169
175
|
/**
|
|
170
|
-
* Set to `
|
|
171
|
-
*
|
|
176
|
+
* Set to `button` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active.
|
|
177
|
+
*
|
|
178
|
+
* Default value is `"never"`.
|
|
172
179
|
*/
|
|
173
|
-
enableReverse?:
|
|
180
|
+
enableReverse?: EnableReverse;
|
|
174
181
|
/**
|
|
175
|
-
*
|
|
182
|
+
* Reverse mode active.
|
|
183
|
+
*
|
|
176
184
|
* Default value is `false`.
|
|
177
185
|
*/
|
|
178
186
|
reverseActive?: boolean;
|
|
179
187
|
/**
|
|
180
|
-
*
|
|
188
|
+
* Title of the reverse toggle button.
|
|
189
|
+
*
|
|
181
190
|
* Default value is `"toggle reverse geocoding"`.
|
|
182
191
|
*/
|
|
183
192
|
reverseButtonTitle?: string;
|
|
184
193
|
/**
|
|
185
|
-
*
|
|
194
|
+
* Title of the clear button.
|
|
195
|
+
*
|
|
186
196
|
* Default value is `"clear"`.
|
|
187
197
|
*/
|
|
188
198
|
clearButtonTitle?: string;
|
|
189
199
|
/**
|
|
190
|
-
* Set to `
|
|
191
|
-
* If set to `"
|
|
192
|
-
*
|
|
200
|
+
* Set to `"never"` to hide place/POI type. If set to `"always"` then type is shown for all items.
|
|
201
|
+
* If set to `"if-needed"` then type is shown only for places/POIs not determined from the icon.
|
|
202
|
+
*
|
|
203
|
+
* Default value is `"if-needed"`.
|
|
193
204
|
*/
|
|
194
|
-
showPlaceType?:
|
|
205
|
+
showPlaceType?: ShowPlaceType;
|
|
195
206
|
/**
|
|
196
|
-
*
|
|
207
|
+
* Style of the picked result on the map:
|
|
208
|
+
*
|
|
209
|
+
* - `"marker-only"` - show only marker at the center of the feature
|
|
210
|
+
* - `"full-geometry"` - show full feature geometry of the chosen result
|
|
211
|
+
* - `"full-geometry-including-polygon-center-marker"` - show full feature geometry of the chosen result together with a marker in the center of polygon feature
|
|
212
|
+
*
|
|
197
213
|
* Default value is `true`.
|
|
198
214
|
*/
|
|
199
|
-
|
|
215
|
+
pickedResultStyle?: PickedResultStyle;
|
|
200
216
|
/**
|
|
201
217
|
* Limit search to specified country(ies).
|
|
218
|
+
*
|
|
202
219
|
* Default value is `undefined` - use all countries.
|
|
203
220
|
*/
|
|
204
221
|
country?: string | string[];
|
|
205
222
|
/**
|
|
206
223
|
* Filter of feature types to return.
|
|
224
|
+
*
|
|
207
225
|
* Default value is `undefined` - all available feature types are returned.
|
|
208
226
|
*/
|
|
209
227
|
types?: string[];
|
|
210
228
|
/**
|
|
211
229
|
* Use `limit` value for reverse geocoding even if `types` is not an array with a single element.
|
|
212
230
|
* Will work only if enabled on the server.
|
|
231
|
+
*
|
|
213
232
|
* Default value is `false`.
|
|
214
233
|
*/
|
|
215
234
|
exhaustiveReverseGeocoding?: boolean;
|
|
216
235
|
/**
|
|
217
236
|
* If set to `true` then use all types except for those listed in `types`.
|
|
237
|
+
*
|
|
218
238
|
* Default value is `false`.
|
|
219
239
|
*/
|
|
220
240
|
excludeTypes?: boolean;
|
|
221
241
|
/**
|
|
222
242
|
* Geocoding API URL.
|
|
243
|
+
*
|
|
223
244
|
* Default value is MapTiler Geocoding API URL.
|
|
224
245
|
*/
|
|
225
246
|
apiUrl?: string;
|
|
226
247
|
/**
|
|
227
248
|
* Extra fetch parameters.
|
|
249
|
+
*
|
|
228
250
|
* Default value is `undefined`.
|
|
229
251
|
*/
|
|
230
252
|
fetchParameters?: RequestInit;
|
|
231
253
|
/**
|
|
232
254
|
* Base URL for POI icons.
|
|
255
|
+
*
|
|
233
256
|
* Default value is `"icons/"` for Svelte apps, otherwise `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"`.
|
|
234
257
|
*/
|
|
235
258
|
iconsBaseUrl?: string;
|
|
236
259
|
/**
|
|
237
260
|
* Function to adjust URL search parameters.
|
|
261
|
+
*
|
|
238
262
|
* Default value is empty function.
|
|
239
263
|
*/
|
|
240
264
|
adjustUrlQuery?: (sp: URLSearchParams) => void;
|
|
@@ -257,16 +281,41 @@ export type ControlOptions = {
|
|
|
257
281
|
*/
|
|
258
282
|
markerOnSelected?: boolean;
|
|
259
283
|
};
|
|
260
|
-
export type
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
284
|
+
export type PickedResultStyle = "marker-only" | "full-geometry" | "full-geometry-including-polygon-center-marker";
|
|
285
|
+
export type EnableReverse = "never" | "always" | "button";
|
|
286
|
+
export type ShowPlaceType = "never" | "always" | "if-needed";
|
|
287
|
+
export type DispatcherTypeCC = {
|
|
288
|
+
featuresListed: {
|
|
289
|
+
features: Feature[] | undefined;
|
|
290
|
+
};
|
|
291
|
+
featuresMarked: {
|
|
292
|
+
features: Feature[] | undefined;
|
|
293
|
+
};
|
|
294
|
+
optionsVisibilityChange: {
|
|
295
|
+
optionsVisible: boolean;
|
|
296
|
+
};
|
|
297
|
+
pick: {
|
|
298
|
+
feature: Feature | undefined;
|
|
299
|
+
};
|
|
300
|
+
queryChange: {
|
|
301
|
+
query: string;
|
|
302
|
+
};
|
|
266
303
|
response: {
|
|
267
304
|
url: string;
|
|
268
305
|
featureCollection: FeatureCollection;
|
|
269
306
|
};
|
|
270
|
-
reverseToggle:
|
|
271
|
-
|
|
307
|
+
reverseToggle: {
|
|
308
|
+
reverse: boolean;
|
|
309
|
+
};
|
|
310
|
+
select: {
|
|
311
|
+
feature: Feature | undefined;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
export type DispatcherType = {
|
|
315
|
+
[T in keyof DispatcherTypeCC as Lowercase<T>]: DispatcherTypeCC[T];
|
|
272
316
|
};
|
|
317
|
+
export type RedefineType<OriginalType, UpdatedType extends {
|
|
318
|
+
[K in keyof OriginalType]: OriginalType[K];
|
|
319
|
+
} & {
|
|
320
|
+
[K in Exclude<keyof UpdatedType, keyof OriginalType>]: never;
|
|
321
|
+
}> = UpdatedType;
|
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 {};
|
package/svelte/vanilla.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GeocodingControlComponent from "./GeocodingControl.svelte";
|
|
2
2
|
const finalizationRegistry = new FinalizationRegistry((gc) => {
|
|
3
3
|
gc.$destroy();
|
|
4
4
|
});
|
|
@@ -6,22 +6,31 @@ export class GeocodingControl extends EventTarget {
|
|
|
6
6
|
#gc;
|
|
7
7
|
constructor({ target, ...options }) {
|
|
8
8
|
super();
|
|
9
|
-
this.#gc = new
|
|
9
|
+
this.#gc = new GeocodingControlComponent({
|
|
10
10
|
target,
|
|
11
11
|
props: options,
|
|
12
12
|
});
|
|
13
13
|
for (const eventName of [
|
|
14
14
|
"select",
|
|
15
15
|
"pick",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"featureslisted",
|
|
17
|
+
"featuresmarked",
|
|
18
18
|
"response",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"optionsvisibilitychange",
|
|
20
|
+
"reversetoggle",
|
|
21
|
+
"querychange",
|
|
22
22
|
]) {
|
|
23
|
-
this.#gc.$on(eventName, (event) =>
|
|
23
|
+
this.#gc.$on(eventName, (event) => {
|
|
24
|
+
// Use the new `emit` method for type-safe dispatching
|
|
25
|
+
this.#emit(eventName, event.detail);
|
|
26
|
+
});
|
|
24
27
|
}
|
|
28
|
+
this.#gc.$on("select", (event) => {
|
|
29
|
+
const geocodingEvent = new CustomEvent(event.type, {
|
|
30
|
+
detail: event.detail,
|
|
31
|
+
});
|
|
32
|
+
this.dispatchEvent(geocodingEvent);
|
|
33
|
+
});
|
|
25
34
|
finalizationRegistry.register(this, this.#gc);
|
|
26
35
|
}
|
|
27
36
|
setOptions(options) {
|
|
@@ -42,4 +51,18 @@ export class GeocodingControl extends EventTarget {
|
|
|
42
51
|
blur() {
|
|
43
52
|
this.#gc?.blur();
|
|
44
53
|
}
|
|
54
|
+
addEventListener(type, callback, options) {
|
|
55
|
+
super.addEventListener(type, callback, options);
|
|
56
|
+
}
|
|
57
|
+
removeEventListener(type, callback, options) {
|
|
58
|
+
super.removeEventListener(type, callback, options);
|
|
59
|
+
}
|
|
60
|
+
dispatchEvent(event) {
|
|
61
|
+
return super.dispatchEvent(event);
|
|
62
|
+
}
|
|
63
|
+
#emit(type, detail) {
|
|
64
|
+
return super.dispatchEvent(new CustomEvent(type, {
|
|
65
|
+
detail,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
45
68
|
}
|