@maptiler/geocoding-control 2.0.0-rc.5 → 2.0.0-rc.7
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 +1 -18
- package/leaflet-controller.d.ts +2 -3
- package/leaflet-controller.js +450 -453
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +3 -3
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.js +949 -954
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +3 -3
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.d.ts +2 -3
- package/maplibregl-controller.js +140 -143
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +2 -2
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.d.ts +0 -17
- package/maplibregl.js +1673 -1680
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.d.ts +0 -17
- package/maptilersdk.js +1670 -1677
- package/maptilersdk.js.map +1 -1
- package/maptilersdk.umd.js +3 -3
- package/maptilersdk.umd.js.map +1 -1
- package/openlayers-controller.d.ts +2 -3
- package/openlayers-controller.js +366 -369
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +3 -3
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.js +1075 -1079
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +3 -3
- package/openlayers.umd.js.map +1 -1
- package/package.json +1 -1
- package/react.js +739 -737
- package/react.js.map +1 -1
- package/react.umd.js +1 -1
- package/react.umd.js.map +1 -1
- package/svelte/GeocodingControl.svelte +7 -5
- package/svelte/MapLibreBasedGeocodingControl.d.ts +1 -18
- package/svelte/MapLibreBasedGeocodingControl.js +2 -7
- package/svelte/leaflet-controller.d.ts +2 -3
- package/svelte/leaflet-controller.js +3 -7
- package/svelte/leaflet.js +2 -7
- package/svelte/maplibregl-controller.d.ts +2 -3
- package/svelte/maplibregl-controller.js +3 -7
- package/svelte/maplibregl.d.ts +0 -17
- package/svelte/maptilersdk.d.ts +0 -17
- package/svelte/openlayers-controller.d.ts +2 -3
- package/svelte/openlayers-controller.js +3 -7
- package/svelte/openlayers.js +2 -5
- package/svelte/types.d.ts +1 -2
- package/types.d.ts +1 -2
- package/vanilla.js +760 -758
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
|
@@ -73,7 +73,7 @@ export let zoom = ZOOM_DEFAULTS;
|
|
|
73
73
|
export let apiUrl = "https://api.maptiler.com/geocoding";
|
|
74
74
|
export let fetchParameters = {};
|
|
75
75
|
export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
|
|
76
|
-
"2.0.0-rc.
|
|
76
|
+
"2.0.0-rc.7" +
|
|
77
77
|
"/icons/";
|
|
78
78
|
export let adjustUrlQuery = () => { };
|
|
79
79
|
export function focus() {
|
|
@@ -148,19 +148,21 @@ $: {
|
|
|
148
148
|
$: if (mapController && selected && flyTo && flyToSelected) {
|
|
149
149
|
mapController.flyTo(selected.center, computeZoom(selected));
|
|
150
150
|
}
|
|
151
|
+
$: showPolygonMarker =
|
|
152
|
+
pickedResultStyle === "full-geometry-including-polygon-center-marker";
|
|
151
153
|
// if markerOnSelected was dynamically changed to false
|
|
152
154
|
$: if (!markerOnSelected) {
|
|
153
|
-
mapController?.setMarkers(undefined, undefined);
|
|
155
|
+
mapController?.setMarkers(undefined, undefined, showPolygonMarker);
|
|
154
156
|
}
|
|
155
157
|
$: if (mapController && markerOnSelected && !markedFeatures) {
|
|
156
|
-
mapController.setMarkers(selected ? [selected] : undefined, undefined);
|
|
158
|
+
mapController.setMarkers(selected ? [selected] : undefined, undefined, showPolygonMarker);
|
|
157
159
|
mapController.setSelectedMarker(selected ? 0 : -1);
|
|
158
160
|
}
|
|
159
161
|
$: if (markedFeatures !== listFeatures) {
|
|
160
162
|
markedFeatures = undefined;
|
|
161
163
|
}
|
|
162
164
|
$: if (mapController) {
|
|
163
|
-
mapController.setMarkers(markedFeatures, picked);
|
|
165
|
+
mapController.setMarkers(markedFeatures, picked, showPolygonMarker);
|
|
164
166
|
}
|
|
165
167
|
$: if (searchValue.length < minLength) {
|
|
166
168
|
picked = undefined;
|
|
@@ -242,7 +244,7 @@ onDestroy(() => {
|
|
|
242
244
|
mapController.setEventHandler(undefined);
|
|
243
245
|
mapController.indicateReverse(false);
|
|
244
246
|
mapController.setSelectedMarker(-1);
|
|
245
|
-
mapController.setMarkers(undefined, undefined);
|
|
247
|
+
mapController.setMarkers(undefined, undefined, false);
|
|
246
248
|
}
|
|
247
249
|
});
|
|
248
250
|
function handleOnSubmit(event) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Evented, FitBoundsOptions, FlyToOptions, Map, Marker, MarkerOptions } from "maplibre-gl";
|
|
2
2
|
import type { SvelteComponent } from "svelte";
|
|
3
3
|
import GeocodingControlComponent from "./GeocodingControl.svelte";
|
|
4
|
-
import {
|
|
4
|
+
import { type FullGeometryStyle, type MapLibreGL } from "./maplibregl-controller";
|
|
5
5
|
import type { ControlOptions, Feature, FeatureCollection } from "./types";
|
|
6
6
|
export { createMapLibreGlMapController, type MapLibreGL, } from "./maplibregl-controller";
|
|
7
7
|
export type MapLibreBaseControlOptions = Omit<ControlOptions, "apiKey"> & {
|
|
@@ -65,7 +65,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
65
65
|
new (options?: OPTS): {
|
|
66
66
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
67
67
|
"__#1@#options": OPTS;
|
|
68
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
69
68
|
onAddInt(map: Map): HTMLElement;
|
|
70
69
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
71
70
|
select: {
|
|
@@ -220,7 +219,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
220
219
|
new (target: {
|
|
221
220
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
222
221
|
"__#1@#options": OPTS;
|
|
223
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
224
222
|
onAddInt(map: Map): HTMLElement;
|
|
225
223
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
226
224
|
select: {
|
|
@@ -376,7 +374,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
376
374
|
readonly target: {
|
|
377
375
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
378
376
|
"__#1@#options": OPTS;
|
|
379
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
380
377
|
onAddInt(map: Map): HTMLElement;
|
|
381
378
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
382
379
|
select: {
|
|
@@ -531,7 +528,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
531
528
|
new (target: {
|
|
532
529
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
533
530
|
"__#1@#options": OPTS;
|
|
534
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
535
531
|
onAddInt(map: Map): HTMLElement;
|
|
536
532
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
537
533
|
select: {
|
|
@@ -685,7 +681,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
685
681
|
readonly target: {
|
|
686
682
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
687
683
|
"__#1@#options": OPTS;
|
|
688
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
689
684
|
onAddInt(map: Map): HTMLElement;
|
|
690
685
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
691
686
|
select: {
|
|
@@ -840,7 +835,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
840
835
|
new (target: {
|
|
841
836
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
842
837
|
"__#1@#options": OPTS;
|
|
843
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
844
838
|
onAddInt(map: Map): HTMLElement;
|
|
845
839
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
846
840
|
select: {
|
|
@@ -994,7 +988,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
994
988
|
readonly target: {
|
|
995
989
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
996
990
|
"__#1@#options": OPTS;
|
|
997
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
998
991
|
onAddInt(map: Map): HTMLElement;
|
|
999
992
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1000
993
|
select: {
|
|
@@ -1149,7 +1142,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1149
1142
|
new (target: {
|
|
1150
1143
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1151
1144
|
"__#1@#options": OPTS;
|
|
1152
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1153
1145
|
onAddInt(map: Map): HTMLElement;
|
|
1154
1146
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1155
1147
|
select: {
|
|
@@ -1303,7 +1295,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1303
1295
|
readonly target: {
|
|
1304
1296
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1305
1297
|
"__#1@#options": OPTS;
|
|
1306
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1307
1298
|
onAddInt(map: Map): HTMLElement;
|
|
1308
1299
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1309
1300
|
select: {
|
|
@@ -1458,7 +1449,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1458
1449
|
new (target: {
|
|
1459
1450
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1460
1451
|
"__#1@#options": OPTS;
|
|
1461
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1462
1452
|
onAddInt(map: Map): HTMLElement;
|
|
1463
1453
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1464
1454
|
select: {
|
|
@@ -1612,7 +1602,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1612
1602
|
readonly target: {
|
|
1613
1603
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1614
1604
|
"__#1@#options": OPTS;
|
|
1615
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1616
1605
|
onAddInt(map: Map): HTMLElement;
|
|
1617
1606
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1618
1607
|
select: {
|
|
@@ -1767,7 +1756,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1767
1756
|
new (target: {
|
|
1768
1757
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1769
1758
|
"__#1@#options": OPTS;
|
|
1770
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1771
1759
|
onAddInt(map: Map): HTMLElement;
|
|
1772
1760
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1773
1761
|
select: {
|
|
@@ -1921,7 +1909,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
1921
1909
|
readonly target: {
|
|
1922
1910
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
1923
1911
|
"__#1@#options": OPTS;
|
|
1924
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
1925
1912
|
onAddInt(map: Map): HTMLElement;
|
|
1926
1913
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1927
1914
|
select: {
|
|
@@ -2076,7 +2063,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
2076
2063
|
new (target: {
|
|
2077
2064
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
2078
2065
|
"__#1@#options": OPTS;
|
|
2079
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
2080
2066
|
onAddInt(map: Map): HTMLElement;
|
|
2081
2067
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2082
2068
|
select: {
|
|
@@ -2231,7 +2217,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
2231
2217
|
readonly target: {
|
|
2232
2218
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
2233
2219
|
"__#1@#options": OPTS;
|
|
2234
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
2235
2220
|
onAddInt(map: Map): HTMLElement;
|
|
2236
2221
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2237
2222
|
select: {
|
|
@@ -2386,7 +2371,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
2386
2371
|
new (target: {
|
|
2387
2372
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
2388
2373
|
"__#1@#options": OPTS;
|
|
2389
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
2390
2374
|
onAddInt(map: Map): HTMLElement;
|
|
2391
2375
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2392
2376
|
select: {
|
|
@@ -2540,7 +2524,6 @@ export declare function crateClasses<OPTS extends MapLibreBaseControlOptions>(Ev
|
|
|
2540
2524
|
readonly target: {
|
|
2541
2525
|
"__#1@#gc"?: GeocodingControlComponent;
|
|
2542
2526
|
"__#1@#options": OPTS;
|
|
2543
|
-
"__#1@#mapController"?: ReturnType<typeof createMapLibreGlMapController>;
|
|
2544
2527
|
onAddInt(map: Map): HTMLElement;
|
|
2545
2528
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2546
2529
|
select: {
|
|
@@ -72,7 +72,6 @@ export function crateClasses(Evented, maplibreGl, getExtraProps) {
|
|
|
72
72
|
class MapLibreBasedGeocodingControl extends Evented {
|
|
73
73
|
#gc;
|
|
74
74
|
#options;
|
|
75
|
-
#mapController = undefined;
|
|
76
75
|
constructor(options = {}) {
|
|
77
76
|
super();
|
|
78
77
|
this.#options = options;
|
|
@@ -83,9 +82,7 @@ export function crateClasses(Evented, maplibreGl, getExtraProps) {
|
|
|
83
82
|
"mapboxgl-ctrl-geocoder mapboxgl-ctrl maplibregl-ctrl-geocoder maplibregl-ctrl mapboxgl-ctrl-group";
|
|
84
83
|
const { marker, showResultMarkers, flyTo, fullGeometryStyle, ...restOptions } = this.#options;
|
|
85
84
|
const flyToOptions = typeof flyTo === "boolean" ? {} : flyTo;
|
|
86
|
-
const mapController = createMapLibreGlMapController(map, maplibreGl, marker, showResultMarkers, flyToOptions, flyToOptions, fullGeometryStyle
|
|
87
|
-
"full-geometry-including-polygon-center-marker");
|
|
88
|
-
this.#mapController = mapController;
|
|
85
|
+
const mapController = createMapLibreGlMapController(map, maplibreGl, marker, showResultMarkers, flyToOptions, flyToOptions, fullGeometryStyle);
|
|
89
86
|
const props = {
|
|
90
87
|
mapController,
|
|
91
88
|
flyTo: flyTo === undefined ? true : !!flyTo,
|
|
@@ -136,11 +133,9 @@ export function crateClasses(Evented, maplibreGl, getExtraProps) {
|
|
|
136
133
|
return super.listens(type);
|
|
137
134
|
}
|
|
138
135
|
setOptions(options) {
|
|
139
|
-
this.#options
|
|
136
|
+
Object.assign(this.#options, options);
|
|
140
137
|
const { marker, showResultMarkers, flyTo, fullGeometryStyle, ...restOptions } = this.#options;
|
|
141
138
|
this.#gc?.$set(restOptions);
|
|
142
|
-
this.#mapController?.setShowPolygonMarker(options.pickedResultStyle ===
|
|
143
|
-
"full-geometry-including-polygon-center-marker");
|
|
144
139
|
}
|
|
145
140
|
setQuery(value, submit = true) {
|
|
146
141
|
this.#gc?.setQuery(value, submit);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as L from "leaflet";
|
|
2
2
|
import type { BBox, Feature, MapEvent, Position } from "./types";
|
|
3
|
-
export declare function createLeafletMapController(map: L.Map, marker?: boolean | null | L.MarkerOptions | ((map: L.Map, feature?: Feature) => L.Marker | undefined | null), showResultMarkers?: boolean | null | L.MarkerOptions | ((map: L.Map, feature: Feature) => L.Marker | undefined | null), flyToOptions?: L.ZoomPanOptions | null, flyToBounds?: L.FitBoundsOptions | null, fullGeometryStyle?: null | boolean | L.PathOptions | L.StyleFunction
|
|
3
|
+
export declare function createLeafletMapController(map: L.Map, marker?: boolean | null | L.MarkerOptions | ((map: L.Map, feature?: Feature) => L.Marker | undefined | null), showResultMarkers?: boolean | null | L.MarkerOptions | ((map: L.Map, feature: Feature) => L.Marker | undefined | null), flyToOptions?: L.ZoomPanOptions | null, flyToBounds?: L.FitBoundsOptions | null, fullGeometryStyle?: null | boolean | L.PathOptions | L.StyleFunction): {
|
|
4
4
|
setEventHandler(handler: undefined | ((e: MapEvent) => void)): void;
|
|
5
5
|
flyTo(center: Position, zoom?: number): void;
|
|
6
6
|
fitBounds(bbox: BBox, padding: number, maxZoom?: number): void;
|
|
7
7
|
indicateReverse(reverse: boolean): void;
|
|
8
8
|
setReverseMarker(coordinates?: Position): void;
|
|
9
|
-
setMarkers(markedFeatures: Feature[] | undefined, picked: Feature | undefined): void;
|
|
9
|
+
setMarkers(markedFeatures: Feature[] | undefined, picked: Feature | undefined, showPolygonMarker: boolean): void;
|
|
10
10
|
setSelectedMarker(index: number): void;
|
|
11
11
|
getCenterAndZoom(): [number, number, number];
|
|
12
|
-
setShowPolygonMarker(showPolygonMarker: boolean): void;
|
|
13
12
|
};
|
|
@@ -22,12 +22,11 @@ const defaultFullGeometryStyle = (feature) => {
|
|
|
22
22
|
lineCap: "butt",
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
export function createLeafletMapController(map, marker = true, showResultMarkers = true, flyToOptions = {}, flyToBounds = {}, fullGeometryStyle = defaultFullGeometryStyle
|
|
25
|
+
export function createLeafletMapController(map, marker = true, showResultMarkers = true, flyToOptions = {}, flyToBounds = {}, fullGeometryStyle = defaultFullGeometryStyle) {
|
|
26
26
|
let eventHandler;
|
|
27
27
|
const markers = [];
|
|
28
28
|
let selectedMarker;
|
|
29
29
|
let reverseMarker;
|
|
30
|
-
let _showPolygonMarker = showPolygonMarker;
|
|
31
30
|
const resultLayer = L.geoJSON(undefined, {
|
|
32
31
|
style: fullGeometryStyle === true
|
|
33
32
|
? defaultFullGeometryStyle
|
|
@@ -110,7 +109,7 @@ export function createLeafletMapController(map, marker = true, showResultMarkers
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
},
|
|
113
|
-
setMarkers(markedFeatures, picked) {
|
|
112
|
+
setMarkers(markedFeatures, picked, showPolygonMarker) {
|
|
114
113
|
function setData(data) {
|
|
115
114
|
resultLayer.clearLayers();
|
|
116
115
|
if (data) {
|
|
@@ -178,7 +177,7 @@ export function createLeafletMapController(map, marker = true, showResultMarkers
|
|
|
178
177
|
setData(picked);
|
|
179
178
|
return; // no pin for (multi)linestrings
|
|
180
179
|
}
|
|
181
|
-
if (!
|
|
180
|
+
if (!showPolygonMarker && picked.geometry.type !== "Point") {
|
|
182
181
|
return;
|
|
183
182
|
}
|
|
184
183
|
if (marker instanceof Function) {
|
|
@@ -250,9 +249,6 @@ export function createLeafletMapController(map, marker = true, showResultMarkers
|
|
|
250
249
|
const c = map.getCenter();
|
|
251
250
|
return [map.getZoom(), c.lng, c.lat];
|
|
252
251
|
},
|
|
253
|
-
setShowPolygonMarker(showPolygonMarker) {
|
|
254
|
-
_showPolygonMarker = showPolygonMarker;
|
|
255
|
-
},
|
|
256
252
|
};
|
|
257
253
|
}
|
|
258
254
|
function shiftPolyCollection(featureCollection, distance) {
|
package/svelte/leaflet.js
CHANGED
|
@@ -14,7 +14,6 @@ L.Util.extend(EventedControl.prototype, L.Evented.prototype);
|
|
|
14
14
|
export class GeocodingControl extends EventedControl {
|
|
15
15
|
#gc;
|
|
16
16
|
#options;
|
|
17
|
-
#mapController = undefined;
|
|
18
17
|
constructor(options) {
|
|
19
18
|
super(options);
|
|
20
19
|
this.#options = options;
|
|
@@ -26,9 +25,7 @@ export class GeocodingControl extends EventedControl {
|
|
|
26
25
|
L.DomEvent.disableScrollPropagation(div);
|
|
27
26
|
const { marker, showResultMarkers, flyTo, fullGeometryStyle, position, ...restOptions } = this.#options;
|
|
28
27
|
const flyToOptions = typeof flyTo === "boolean" ? {} : flyTo;
|
|
29
|
-
const mapController = createLeafletMapController(map, marker, showResultMarkers, flyToOptions, flyToOptions, fullGeometryStyle
|
|
30
|
-
"full-geometry-including-polygon-center-marker");
|
|
31
|
-
this.#mapController = mapController;
|
|
28
|
+
const mapController = createLeafletMapController(map, marker, showResultMarkers, flyToOptions, flyToOptions, fullGeometryStyle);
|
|
32
29
|
this.#gc = new GeocodingControlComponent({
|
|
33
30
|
target: div,
|
|
34
31
|
props: {
|
|
@@ -53,11 +50,9 @@ export class GeocodingControl extends EventedControl {
|
|
|
53
50
|
return div;
|
|
54
51
|
}
|
|
55
52
|
setOptions(options) {
|
|
56
|
-
this.#options
|
|
53
|
+
Object.assign(this.#options, options);
|
|
57
54
|
const { marker, showResultMarkers, flyTo, fullGeometryStyle, ...restOptions } = this.#options;
|
|
58
55
|
this.#gc?.$set(restOptions);
|
|
59
|
-
this.#mapController?.setShowPolygonMarker(options.pickedResultStyle ===
|
|
60
|
-
"full-geometry-including-polygon-center-marker");
|
|
61
56
|
}
|
|
62
57
|
setQuery(value, submit = true) {
|
|
63
58
|
this.#gc?.setQuery(value, submit);
|
|
@@ -7,14 +7,13 @@ export type FullGeometryStyle = {
|
|
|
7
7
|
fill: Pick<FillLayerSpecification, "layout" | "paint" | "filter">;
|
|
8
8
|
line: Pick<LineLayerSpecification, "layout" | "paint" | "filter">;
|
|
9
9
|
};
|
|
10
|
-
export declare function createMapLibreGlMapController(map: Map, maplibregl?: MapLibreGL | undefined, marker?: boolean | null | MarkerOptions | ((map: Map, feature?: Feature) => Marker | undefined | null), showResultMarkers?: boolean | null | MarkerOptions | ((map: Map, feature: Feature) => Marker | undefined | null), flyToOptions?: FlyToOptions | null, fitBoundsOptions?: FitBoundsOptions | null, fullGeometryStyle?: boolean | null | FullGeometryStyle
|
|
10
|
+
export declare function createMapLibreGlMapController(map: Map, maplibregl?: MapLibreGL | undefined, marker?: boolean | null | MarkerOptions | ((map: Map, feature?: Feature) => Marker | undefined | null), showResultMarkers?: boolean | null | MarkerOptions | ((map: Map, feature: Feature) => Marker | undefined | null), flyToOptions?: FlyToOptions | null, fitBoundsOptions?: FitBoundsOptions | null, fullGeometryStyle?: boolean | null | FullGeometryStyle): {
|
|
11
11
|
setEventHandler(handler: undefined | ((e: MapEvent) => void)): void;
|
|
12
12
|
flyTo(center: Position, zoom?: number): void;
|
|
13
13
|
fitBounds(bbox: BBox, padding: number, maxZoom?: number): void;
|
|
14
14
|
indicateReverse(reverse: boolean): void;
|
|
15
15
|
setReverseMarker(coordinates?: Position): void;
|
|
16
|
-
setMarkers(markedFeatures: Feature[] | undefined, picked: Feature | undefined): void;
|
|
16
|
+
setMarkers(markedFeatures: Feature[] | undefined, picked: Feature | undefined, showPolygonMarker: boolean): void;
|
|
17
17
|
setSelectedMarker(index: number): void;
|
|
18
18
|
getCenterAndZoom(): [number, number, number];
|
|
19
|
-
setShowPolygonMarker(showPolygonMarker: boolean): void;
|
|
20
19
|
};
|
|
@@ -25,13 +25,12 @@ const defaultGeometryStyle = {
|
|
|
25
25
|
const RESULT_SOURCE = "mtlr-gc-full-geom";
|
|
26
26
|
const RESULT_LAYER_FILL = "mtlr-gc-full-geom-fill";
|
|
27
27
|
const RESULT_LAYER_LINE = "mtlr-gc-full-geom-line";
|
|
28
|
-
export function createMapLibreGlMapController(map, maplibregl, marker = true, showResultMarkers = true, flyToOptions = {}, fitBoundsOptions = {}, fullGeometryStyle = defaultGeometryStyle
|
|
28
|
+
export function createMapLibreGlMapController(map, maplibregl, marker = true, showResultMarkers = true, flyToOptions = {}, fitBoundsOptions = {}, fullGeometryStyle = defaultGeometryStyle) {
|
|
29
29
|
let eventHandler;
|
|
30
30
|
const markers = [];
|
|
31
31
|
let selectedMarker;
|
|
32
32
|
let reverseMarker;
|
|
33
33
|
let savedData; // used to restore features on style switch
|
|
34
|
-
let _showPolygonMarker = showPolygonMarker;
|
|
35
34
|
function syncFullGeometryLayer() {
|
|
36
35
|
if (!map.loaded) {
|
|
37
36
|
map.once("load", syncFullGeometryLayer);
|
|
@@ -157,7 +156,7 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
},
|
|
160
|
-
setMarkers(markedFeatures, picked) {
|
|
159
|
+
setMarkers(markedFeatures, picked, showPolygonMarker) {
|
|
161
160
|
for (const marker of markers) {
|
|
162
161
|
marker.remove();
|
|
163
162
|
}
|
|
@@ -205,7 +204,7 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
205
204
|
setAndSaveData(picked);
|
|
206
205
|
return; // no pin for (multi)linestrings
|
|
207
206
|
}
|
|
208
|
-
if (!
|
|
207
|
+
if (!showPolygonMarker && picked.geometry.type !== "Point") {
|
|
209
208
|
return;
|
|
210
209
|
}
|
|
211
210
|
if (marker instanceof Function) {
|
|
@@ -276,8 +275,5 @@ export function createMapLibreGlMapController(map, maplibregl, marker = true, sh
|
|
|
276
275
|
const c = map.getCenter();
|
|
277
276
|
return [map.getZoom(), c.lng, c.lat];
|
|
278
277
|
},
|
|
279
|
-
setShowPolygonMarker(showPolygonMarker) {
|
|
280
|
-
_showPolygonMarker = showPolygonMarker;
|
|
281
|
-
},
|
|
282
278
|
};
|
|
283
279
|
}
|
package/svelte/maplibregl.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare const MapLibreBasedGeocodingControl: {
|
|
|
12
12
|
new (options?: Options): {
|
|
13
13
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
14
14
|
"__#1@#options": Options;
|
|
15
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
16
15
|
onAddInt(map: Map): HTMLElement;
|
|
17
16
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
18
17
|
select: {
|
|
@@ -169,7 +168,6 @@ export declare const SelectEvent: {
|
|
|
169
168
|
new (target: {
|
|
170
169
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
171
170
|
"__#1@#options": Options;
|
|
172
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
173
171
|
onAddInt(map: Map): HTMLElement;
|
|
174
172
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
175
173
|
select: {
|
|
@@ -325,7 +323,6 @@ export declare const SelectEvent: {
|
|
|
325
323
|
readonly target: {
|
|
326
324
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
327
325
|
"__#1@#options": Options;
|
|
328
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
329
326
|
onAddInt(map: Map): HTMLElement;
|
|
330
327
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
331
328
|
select: {
|
|
@@ -480,7 +477,6 @@ export declare const FeaturesListedEvent: {
|
|
|
480
477
|
new (target: {
|
|
481
478
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
482
479
|
"__#1@#options": Options;
|
|
483
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
484
480
|
onAddInt(map: Map): HTMLElement;
|
|
485
481
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
486
482
|
select: {
|
|
@@ -634,7 +630,6 @@ export declare const FeaturesListedEvent: {
|
|
|
634
630
|
readonly target: {
|
|
635
631
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
636
632
|
"__#1@#options": Options;
|
|
637
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
638
633
|
onAddInt(map: Map): HTMLElement;
|
|
639
634
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
640
635
|
select: {
|
|
@@ -789,7 +784,6 @@ export declare const FeaturesMarkedEvent: {
|
|
|
789
784
|
new (target: {
|
|
790
785
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
791
786
|
"__#1@#options": Options;
|
|
792
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
793
787
|
onAddInt(map: Map): HTMLElement;
|
|
794
788
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
795
789
|
select: {
|
|
@@ -943,7 +937,6 @@ export declare const FeaturesMarkedEvent: {
|
|
|
943
937
|
readonly target: {
|
|
944
938
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
945
939
|
"__#1@#options": Options;
|
|
946
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
947
940
|
onAddInt(map: Map): HTMLElement;
|
|
948
941
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
949
942
|
select: {
|
|
@@ -1098,7 +1091,6 @@ export declare const OptionsVisibilityChangeEvent: {
|
|
|
1098
1091
|
new (target: {
|
|
1099
1092
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1100
1093
|
"__#1@#options": Options;
|
|
1101
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1102
1094
|
onAddInt(map: Map): HTMLElement;
|
|
1103
1095
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1104
1096
|
select: {
|
|
@@ -1252,7 +1244,6 @@ export declare const OptionsVisibilityChangeEvent: {
|
|
|
1252
1244
|
readonly target: {
|
|
1253
1245
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1254
1246
|
"__#1@#options": Options;
|
|
1255
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1256
1247
|
onAddInt(map: Map): HTMLElement;
|
|
1257
1248
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1258
1249
|
select: {
|
|
@@ -1407,7 +1398,6 @@ export declare const PickEvent: {
|
|
|
1407
1398
|
new (target: {
|
|
1408
1399
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1409
1400
|
"__#1@#options": Options;
|
|
1410
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1411
1401
|
onAddInt(map: Map): HTMLElement;
|
|
1412
1402
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1413
1403
|
select: {
|
|
@@ -1561,7 +1551,6 @@ export declare const PickEvent: {
|
|
|
1561
1551
|
readonly target: {
|
|
1562
1552
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1563
1553
|
"__#1@#options": Options;
|
|
1564
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1565
1554
|
onAddInt(map: Map): HTMLElement;
|
|
1566
1555
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1567
1556
|
select: {
|
|
@@ -1716,7 +1705,6 @@ export declare const QueryChangeEvent: {
|
|
|
1716
1705
|
new (target: {
|
|
1717
1706
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1718
1707
|
"__#1@#options": Options;
|
|
1719
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1720
1708
|
onAddInt(map: Map): HTMLElement;
|
|
1721
1709
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1722
1710
|
select: {
|
|
@@ -1870,7 +1858,6 @@ export declare const QueryChangeEvent: {
|
|
|
1870
1858
|
readonly target: {
|
|
1871
1859
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
1872
1860
|
"__#1@#options": Options;
|
|
1873
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
1874
1861
|
onAddInt(map: Map): HTMLElement;
|
|
1875
1862
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
1876
1863
|
select: {
|
|
@@ -2025,7 +2012,6 @@ export declare const ResponseEvent: {
|
|
|
2025
2012
|
new (target: {
|
|
2026
2013
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
2027
2014
|
"__#1@#options": Options;
|
|
2028
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
2029
2015
|
onAddInt(map: Map): HTMLElement;
|
|
2030
2016
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2031
2017
|
select: {
|
|
@@ -2180,7 +2166,6 @@ export declare const ResponseEvent: {
|
|
|
2180
2166
|
readonly target: {
|
|
2181
2167
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
2182
2168
|
"__#1@#options": Options;
|
|
2183
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
2184
2169
|
onAddInt(map: Map): HTMLElement;
|
|
2185
2170
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2186
2171
|
select: {
|
|
@@ -2335,7 +2320,6 @@ export declare const ReverseToggleEvent: {
|
|
|
2335
2320
|
new (target: {
|
|
2336
2321
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
2337
2322
|
"__#1@#options": Options;
|
|
2338
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
2339
2323
|
onAddInt(map: Map): HTMLElement;
|
|
2340
2324
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2341
2325
|
select: {
|
|
@@ -2489,7 +2473,6 @@ export declare const ReverseToggleEvent: {
|
|
|
2489
2473
|
readonly target: {
|
|
2490
2474
|
"__#1@#gc"?: import("./GeocodingControl.svelte").default;
|
|
2491
2475
|
"__#1@#options": Options;
|
|
2492
|
-
"__#1@#mapController"?: ReturnType<typeof import("./maplibregl-controller").createMapLibreGlMapController>;
|
|
2493
2476
|
onAddInt(map: Map): HTMLElement;
|
|
2494
2477
|
on<T extends "pick" | "response" | "select" | "featureslisted" | "featuresmarked" | "optionsvisibilitychange" | "querychange" | "reversetoggle">(type: T, listener: (ev: {
|
|
2495
2478
|
select: {
|