@maptiler/geocoding-control 2.0.1 → 2.1.0-rc1
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 +1037 -626
- package/icons/10pin.svg +4 -1
- package/icons/9pin.svg +4 -1
- package/icons/alcohol.svg +1 -1
- package/icons/alpine_hut.svg +1 -1
- package/icons/apartment.svg +4 -1
- package/icons/area.svg +1 -5
- package/icons/artwork.svg +4 -1
- package/icons/beauty.svg +14 -1
- package/icons/bicycle_repair_station.svg +18 -1
- package/icons/biergarten.svg +4 -1
- package/icons/books.svg +14 -1
- package/icons/bowl.svg +4 -1
- package/icons/bowling_alley.svg +4 -1
- package/icons/bus_station.svg +1 -1
- package/icons/camping.svg +1 -1
- package/icons/car_repair.svg +14 -1
- package/icons/car_wash.svg +19 -1
- package/icons/cave_entrance.svg +15 -1
- package/icons/chalet.svg +1 -1
- package/icons/chemist.svg +14 -1
- package/icons/church.svg +4 -1
- package/icons/community_centre.svg +20 -1
- package/icons/firestation.svg +4 -1
- package/icons/guest_house.svg +29 -8
- package/icons/hotel.svg +1 -1
- package/icons/housenumber.svg +19 -14
- package/icons/hut.svg +1 -4
- package/icons/medical_supply.svg +20 -1
- package/icons/memorial.svg +14 -1
- package/icons/motel.svg +19 -1
- package/icons/post.svg +1 -1
- package/icons/post_office.svg +1 -1
- package/icons/postal_code.svg +1 -23
- package/icons/public_bookcase.svg +14 -1
- package/icons/public_building.svg +4 -1
- package/icons/shintoist.svg +1 -1
- package/icons/street.svg +11 -14
- package/icons/vehicle_inspection.svg +18 -1
- package/icons/wilderness_hut.svg +1 -1
- package/leaflet-controller.js +32 -31
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +1 -1
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.d.ts +32 -1
- package/leaflet.js +1578 -1402
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +3 -3
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.js +5 -5
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +1 -1
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.d.ts +527 -626
- package/maplibregl.js +1709 -1538
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.d.ts +527 -626
- package/maptilersdk.js +1705 -1534
- package/maptilersdk.js.map +1 -1
- package/maptilersdk.umd.js +3 -3
- package/maptilersdk.umd.js.map +1 -1
- package/openlayers-controller.js +5 -4
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +1 -1
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.d.ts +32 -1
- package/openlayers.js +2009 -1833
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +3 -3
- package/openlayers.umd.js.map +1 -1
- package/package.json +23 -23
- package/react.d.ts +27 -1
- package/react.js +1284 -1128
- 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 +59 -12
- package/svelte/FeatureItem.svelte.d.ts +2 -2
- package/svelte/GeocodingControl.svelte +140 -71
- package/svelte/GeocodingControl.svelte.d.ts +10 -3
- package/svelte/MapLibreBasedGeocodingControl.d.ts +1037 -626
- package/svelte/MapLibreBasedGeocodingControl.js +36 -6
- package/svelte/leaflet-controller.js +3 -3
- package/svelte/leaflet.d.ts +32 -1
- package/svelte/leaflet.js +35 -2
- package/svelte/maplibregl-controller.js +3 -3
- package/svelte/maplibregl.d.ts +527 -626
- package/svelte/maptilersdk.d.ts +527 -626
- package/svelte/openlayers-controller.js +4 -4
- package/svelte/openlayers.d.ts +32 -1
- package/svelte/openlayers.js +36 -3
- package/svelte/react.d.ts +27 -1
- package/svelte/react.js +16 -4
- package/svelte/types.d.ts +23 -1
- package/svelte/vanilla.d.ts +32 -1
- package/svelte/vanilla.js +35 -2
- package/types.d.ts +23 -1
- package/vanilla.d.ts +32 -1
- package/vanilla.js +1153 -978
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
- package/icons/aerodrome.12.svg +0 -1
- package/icons/bus_stop.12.svg +0 -1
- package/icons/elevator.12.svg +0 -1
- /package/icons/{helipad.16.svg → helipad.svg} +0 -0
- /package/icons/{traffic_light.13.svg → traffic_light.svg} +0 -0
package/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
svg.svelte-d2loi5{display:block;fill:#e15042}li.svelte-
|
|
1
|
+
svg.svelte-d2loi5{display:block;fill:#e15042}li.svelte-z7p9pp.svelte-z7p9pp{text-align:left;cursor:default;display:grid;grid-template-columns:40px 1fr;color:var(--color-text);padding:8px 0;font-size:14px;line-height:18px;min-width:fit-content;outline:0}li.svelte-z7p9pp.svelte-z7p9pp:first-child{padding-top:10px}li.svelte-z7p9pp.svelte-z7p9pp:last-child{padding-bottom:10px}li.picked.svelte-z7p9pp.svelte-z7p9pp{background-color:#e7edff}li.picked.svelte-z7p9pp .secondary.svelte-z7p9pp{color:#96a4c7;padding-left:4px}li.picked.svelte-z7p9pp .line2.svelte-z7p9pp{color:#96a4c7}li.selected.svelte-z7p9pp.svelte-z7p9pp{background-color:#f3f6ff}li.selected.svelte-z7p9pp.svelte-z7p9pp{animation:svelte-z7p9pp-backAndForth 5s linear infinite}li.selected.svelte-z7p9pp .primary.svelte-z7p9pp{color:#2b8bfb}li.selected.svelte-z7p9pp .secondary.svelte-z7p9pp{color:#a2adc7;padding-left:4px}li.selected.svelte-z7p9pp .line2.svelte-z7p9pp{color:#a2adc7}li.svelte-z7p9pp>img.svelte-z7p9pp{align-self:center;justify-self:center;opacity:.75}.texts.svelte-z7p9pp.svelte-z7p9pp{padding:0 17px 0 0}.texts.svelte-z7p9pp>.svelte-z7p9pp{white-space:nowrap;display:block;min-width:fit-content}.primary.svelte-z7p9pp.svelte-z7p9pp{font-weight:600}.secondary.svelte-z7p9pp.svelte-z7p9pp{color:#aeb6c7;padding-left:4px}.line2.svelte-z7p9pp.svelte-z7p9pp{color:#aeb6c7}@keyframes svelte-z7p9pp-backAndForth{0%{transform:translate(0)}10%{transform:translate(0)}45%{transform:translate(calc(-100% + 270px))}55%{transform:translate(calc(-100% + 270px))}90%{transform:translate(0)}to{transform:translate(0)}}div.svelte-7cmwmc{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);pointer-events:none;display:flex;align-items:center}svg.svelte-7cmwmc{animation:svelte-7cmwmc-rotate .8s infinite cubic-bezier(.45,.05,.55,.95)}@keyframes svelte-7cmwmc-rotate{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}svg.svelte-gzo3ar.svelte-gzo3ar{display:block;fill:#6b7c93;stroke:#6b7c93}.list-icon.svelte-gzo3ar.svelte-gzo3ar{grid-row:1/3;align-self:center;margin:8px}.in-map.svelte-gzo3ar.svelte-gzo3ar{height:30px}.maplibregl-canvas-container .marker-selected{z-index:1}.maplibregl-canvas-container svg.svelte-gzo3ar path.svelte-gzo3ar,.leaflet-map-pane svg.svelte-gzo3ar path.svelte-gzo3ar{fill:#3170fe;stroke:#3170fe}.marker-selected svg.svelte-gzo3ar path.svelte-gzo3ar{fill:#98b7ff;stroke:#3170fe}.marker-reverse svg.svelte-gzo3ar path.svelte-gzo3ar{fill:silver;stroke:gray}.marker-interactive{cursor:pointer!important}.maptiler-gc-popup>.maplibregl-popup-content{padding:2px 8px}svg.svelte-en2qvf{display:block;fill:var(--color-icon-button)}circle.svelte-1aq105l{stroke-width:1.875;fill:none}path.svelte-1aq105l{stroke-width:1.875;stroke-linecap:round}svg.svelte-1aq105l{display:block;stroke:var(--color-icon-button)}form.svelte-bz0zu3.svelte-bz0zu3{font-family:Open Sans,Ubuntu,Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;background-color:#fff;z-index:10;border-radius:4px;margin:0;transition:max-width .25s;box-shadow:0 2px 5px #33335926;--color-text:#444952;--color-icon-button:#444952}form.svelte-bz0zu3.svelte-bz0zu3,form.svelte-bz0zu3 .svelte-bz0zu3,form.svelte-bz0zu3 .svelte-bz0zu3:after,form.svelte-bz0zu3 .svelte-bz0zu3:before{box-sizing:border-box}form.can-collapse.svelte-bz0zu3.svelte-bz0zu3{max-width:29px}form.can-collapse.svelte-bz0zu3 input.svelte-bz0zu3::placeholder{transition:opacity .25s;opacity:0}form.svelte-bz0zu3.svelte-bz0zu3,form.svelte-bz0zu3.svelte-bz0zu3:focus-within,form.svelte-bz0zu3.svelte-bz0zu3:hover{width:270px;max-width:270px}form.svelte-bz0zu3 input.svelte-bz0zu3::placeholder,form.svelte-bz0zu3:focus-within input.svelte-bz0zu3::placeholder,form.svelte-bz0zu3:hover input.svelte-bz0zu3::placeholder{opacity:1}input.svelte-bz0zu3.svelte-bz0zu3{font:inherit;font-size:14px;flex-grow:1;min-height:29px;background-color:transparent;color:#444952;white-space:nowrap;overflow:hidden;border:0;margin:0;padding:0}input.svelte-bz0zu3.svelte-bz0zu3:focus{color:#444952;outline:0;outline:none;box-shadow:none}ul.svelte-bz0zu3.svelte-bz0zu3,div.error.svelte-bz0zu3.svelte-bz0zu3,div.no-results.svelte-bz0zu3.svelte-bz0zu3{background-color:#fff;border-radius:4px;left:0;list-style:none;margin:0;padding:0;position:absolute;width:100%;top:calc(100% + 6px);overflow:hidden}ul.svelte-bz0zu3.svelte-bz0zu3{font-size:14px;line-height:16px;box-shadow:0 5px 10px #33335926}div.error.svelte-bz0zu3.svelte-bz0zu3,div.no-results.svelte-bz0zu3.svelte-bz0zu3{font:inherit;line-height:18px;font-size:12px;display:flex;gap:16px}div.error.svelte-bz0zu3.svelte-bz0zu3{padding:16px;font-weight:600;color:#e25041;background-color:#fbeae8}div.error.svelte-bz0zu3 div.svelte-bz0zu3{flex-grow:1}div.error.svelte-bz0zu3 svg{flex-shrink:0;width:20px;height:20px}div.error.svelte-bz0zu3 button.svelte-bz0zu3{flex-shrink:0}div.error.svelte-bz0zu3 button.svelte-bz0zu3>svg{width:13px;fill:#e25041}div.error.svelte-bz0zu3 button.svelte-bz0zu3:hover svg,div.error.svelte-bz0zu3 button.svelte-bz0zu3:active svg{fill:#444952}div.no-results.svelte-bz0zu3.svelte-bz0zu3{padding:14px 24px 14px 16px;font-weight:400;color:#6b7c93;box-shadow:0 5px 10px #33335926}div.no-results.svelte-bz0zu3 svg{margin-top:4px;flex-shrink:0;width:20px;height:20px;width:30px;height:30px}.leaflet-bottom ul.options.svelte-bz0zu3.svelte-bz0zu3,.maplibregl-ctrl-bottom-left ul.options.svelte-bz0zu3.svelte-bz0zu3,.maplibregl-ctrl-bottom-right ul.options.svelte-bz0zu3.svelte-bz0zu3{top:auto;bottom:calc(100% + 6px)}button.svelte-bz0zu3.svelte-bz0zu3{padding:0;margin:0;border:0;background-color:transparent;height:auto;width:auto}button.svelte-bz0zu3.svelte-bz0zu3:hover{background-color:transparent}button.svelte-bz0zu3:hover svg,button.svelte-bz0zu3:active svg{fill:#2b8bfb}.input-group.svelte-bz0zu3.svelte-bz0zu3{display:flex;align-items:stretch;gap:7px;padding-inline:8px;border-radius:4px;overflow:hidden}.input-group.svelte-bz0zu3.svelte-bz0zu3:focus-within{outline:#2b8bfb solid 2px}.search-button.svelte-bz0zu3.svelte-bz0zu3{flex-shrink:0}.maplibregl-ctrl-geocoder:not(.maptiler-ctrl) .search-button svg{width:12px!important;transform:translate(.5px)}.clear-button-container.svelte-bz0zu3.svelte-bz0zu3{display:flex;display:none;position:relative;align-items:stretch}.clear-button-container.displayable.svelte-bz0zu3.svelte-bz0zu3{display:flex;flex-shrink:0}.maplibregl-ctrl-geocoder{position:relative;z-index:3}.maptiler-ctrl:not(:empty){box-shadow:none}.maptiler-ctrl .input-group.svelte-bz0zu3.svelte-bz0zu3{padding-inline:8px;border:white solid 2px}.maptiler-ctrl .input-group.svelte-bz0zu3.svelte-bz0zu3:focus-within{border:#2b8bfb solid 2px;outline:0;outline:none}.maptiler-ctrl form.can-collapse.svelte-bz0zu3.svelte-bz0zu3{max-width:33px}.maptiler-ctrl form.svelte-bz0zu3.svelte-bz0zu3,.maptiler-ctrl form.svelte-bz0zu3.svelte-bz0zu3:focus-within,.maptiler-ctrl form.svelte-bz0zu3.svelte-bz0zu3:hover{width:270px;max-width:270px}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
export let feature;
|
|
3
|
+
export let style = "default";
|
|
3
4
|
export let showPlaceType;
|
|
4
5
|
export let missingIconsCache;
|
|
5
6
|
export let iconsBaseUrl;
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
6
8
|
const categories = feature.properties?.categories;
|
|
7
9
|
let category;
|
|
8
10
|
let imageUrl;
|
|
@@ -32,24 +34,51 @@ function handleImgError() {
|
|
|
32
34
|
}
|
|
33
35
|
</script>
|
|
34
36
|
|
|
35
|
-
<!-- svelte-ignore a11y-
|
|
36
|
-
<li
|
|
37
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
38
|
+
<li
|
|
39
|
+
tabindex="-1"
|
|
40
|
+
role="option"
|
|
41
|
+
aria-selected={style === "selected"}
|
|
42
|
+
aria-checked={style === "picked"}
|
|
43
|
+
class={style}
|
|
44
|
+
on:mouseenter
|
|
45
|
+
on:focus={() => dispatch("select", undefined)}
|
|
46
|
+
on:click={(ev) => {
|
|
47
|
+
// this is to trigger the event if we click on focused item
|
|
48
|
+
if (document.activeElement !== ev.target) {
|
|
49
|
+
dispatch("select", undefined);
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
37
53
|
{#if imageUrl}
|
|
38
|
-
<img
|
|
54
|
+
<img
|
|
55
|
+
src={imageUrl}
|
|
56
|
+
alt={category}
|
|
57
|
+
title={placeType}
|
|
58
|
+
on:error={() => handleImgError()}
|
|
59
|
+
/>
|
|
39
60
|
{:else if feature.address}
|
|
40
|
-
<img
|
|
61
|
+
<img
|
|
62
|
+
src={iconsBaseUrl + "housenumber.svg"}
|
|
63
|
+
alt={placeType}
|
|
64
|
+
title={placeType}
|
|
65
|
+
/>
|
|
41
66
|
{:else if feature.id.startsWith("road.")}
|
|
42
|
-
<img src={iconsBaseUrl + "road.svg"} alt={placeType} />
|
|
67
|
+
<img src={iconsBaseUrl + "road.svg"} alt={placeType} title={placeType} />
|
|
43
68
|
{:else if feature.id.startsWith("address.")}
|
|
44
|
-
<img src={iconsBaseUrl + "street.svg"} alt={placeType} />
|
|
69
|
+
<img src={iconsBaseUrl + "street.svg"} alt={placeType} title={placeType} />
|
|
45
70
|
{:else if feature.id.startsWith("postal_code.")}
|
|
46
|
-
<img
|
|
71
|
+
<img
|
|
72
|
+
src={iconsBaseUrl + "postal_code.svg"}
|
|
73
|
+
alt={placeType}
|
|
74
|
+
title={placeType}
|
|
75
|
+
/>
|
|
47
76
|
{:else if feature.id.startsWith("poi.")}
|
|
48
|
-
<img src={iconsBaseUrl + "poi.svg"} alt={placeType} />
|
|
77
|
+
<img src={iconsBaseUrl + "poi.svg"} alt={placeType} title={placeType} />
|
|
49
78
|
{:else if isReverse}
|
|
50
|
-
<img src={iconsBaseUrl + "reverse.svg"} alt={placeType} />
|
|
79
|
+
<img src={iconsBaseUrl + "reverse.svg"} alt={placeType} title={placeType} />
|
|
51
80
|
{:else}
|
|
52
|
-
<img src={iconsBaseUrl + "area.svg"} alt={placeType} />
|
|
81
|
+
<img src={iconsBaseUrl + "area.svg"} alt={placeType} title={placeType} />
|
|
53
82
|
{/if}
|
|
54
83
|
|
|
55
84
|
<span class="texts">
|
|
@@ -81,6 +110,7 @@ function handleImgError() {
|
|
|
81
110
|
font-size: 14px;
|
|
82
111
|
line-height: 18px;
|
|
83
112
|
min-width: fit-content;
|
|
113
|
+
outline: 0;
|
|
84
114
|
}
|
|
85
115
|
li:first-child {
|
|
86
116
|
padding-top: 10px;
|
|
@@ -88,6 +118,16 @@ li:first-child {
|
|
|
88
118
|
li:last-child {
|
|
89
119
|
padding-bottom: 10px;
|
|
90
120
|
}
|
|
121
|
+
li.picked {
|
|
122
|
+
background-color: #e7edff;
|
|
123
|
+
}
|
|
124
|
+
li.picked .secondary {
|
|
125
|
+
color: #96a4c7;
|
|
126
|
+
padding-left: 4px;
|
|
127
|
+
}
|
|
128
|
+
li.picked .line2 {
|
|
129
|
+
color: #96a4c7;
|
|
130
|
+
}
|
|
91
131
|
li.selected {
|
|
92
132
|
background-color: #f3f6ff;
|
|
93
133
|
}
|
|
@@ -97,6 +137,13 @@ li.selected {
|
|
|
97
137
|
li.selected .primary {
|
|
98
138
|
color: #2b8bfb;
|
|
99
139
|
}
|
|
140
|
+
li.selected .secondary {
|
|
141
|
+
color: #a2adc7;
|
|
142
|
+
padding-left: 4px;
|
|
143
|
+
}
|
|
144
|
+
li.selected .line2 {
|
|
145
|
+
color: #a2adc7;
|
|
146
|
+
}
|
|
100
147
|
li > img {
|
|
101
148
|
align-self: center;
|
|
102
149
|
justify-self: center;
|
|
@@ -3,14 +3,14 @@ import type { Feature, ShowPlaceType } from "./types";
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
feature: Feature;
|
|
6
|
-
|
|
6
|
+
style?: "selected" | "picked" | "default";
|
|
7
7
|
showPlaceType: ShowPlaceType;
|
|
8
8
|
missingIconsCache: Set<string>;
|
|
9
9
|
iconsBaseUrl: string;
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
mouseenter: MouseEvent;
|
|
13
|
-
|
|
13
|
+
select: CustomEvent<undefined>;
|
|
14
14
|
} & {
|
|
15
15
|
[evt: string]: CustomEvent<any>;
|
|
16
16
|
};
|
|
@@ -40,6 +40,8 @@ export let apiKey;
|
|
|
40
40
|
export let bbox = undefined;
|
|
41
41
|
export let clearButtonTitle = "clear";
|
|
42
42
|
export let clearOnBlur = false;
|
|
43
|
+
export let clearListOnPick = false;
|
|
44
|
+
export let keepListOpen = false;
|
|
43
45
|
export let collapsed = false;
|
|
44
46
|
export let country = undefined;
|
|
45
47
|
export let debounceSearch = 200;
|
|
@@ -73,39 +75,65 @@ export let zoom = ZOOM_DEFAULTS;
|
|
|
73
75
|
export let apiUrl = "https://api.maptiler.com/geocoding";
|
|
74
76
|
export let fetchParameters = {};
|
|
75
77
|
export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
|
|
76
|
-
"2.0
|
|
78
|
+
"2.1.0-rc1" +
|
|
77
79
|
"/icons/";
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated use `adjustUrl`
|
|
82
|
+
*/
|
|
78
83
|
export let adjustUrlQuery = () => { };
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Adjust geocoding URL before the fetch.
|
|
86
|
+
*/
|
|
87
|
+
export let adjustUrl = () => { };
|
|
88
|
+
/**
|
|
89
|
+
* Focus the search input box.
|
|
90
|
+
*
|
|
91
|
+
* @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
|
|
92
|
+
*/
|
|
93
|
+
export function focus(options) {
|
|
94
|
+
input.focus(options);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Blur the search input box.
|
|
98
|
+
*/
|
|
82
99
|
export function blur() {
|
|
83
100
|
input.blur();
|
|
84
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Set the content of search input box.
|
|
104
|
+
*
|
|
105
|
+
* @param value text to set
|
|
106
|
+
* @param submit perform the search
|
|
107
|
+
*/
|
|
85
108
|
export function setQuery(value, submit = true, reverse = false) {
|
|
86
109
|
searchValue = value;
|
|
87
110
|
if (submit) {
|
|
88
111
|
selectedItemIndex = -1;
|
|
89
|
-
|
|
112
|
+
handleSubmit();
|
|
90
113
|
}
|
|
91
114
|
else {
|
|
92
|
-
handleInput(!reverse, reverse);
|
|
115
|
+
handleInput(undefined, !reverse, reverse);
|
|
93
116
|
setTimeout(() => {
|
|
94
117
|
input.focus();
|
|
95
118
|
input.select();
|
|
96
119
|
});
|
|
97
120
|
}
|
|
98
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Clear search result list.
|
|
124
|
+
*/
|
|
99
125
|
export function clearList() {
|
|
100
126
|
listFeatures = undefined;
|
|
101
127
|
picked = undefined;
|
|
102
128
|
selectedItemIndex = -1;
|
|
103
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Clear geocoding search results from the map.
|
|
132
|
+
*/
|
|
104
133
|
export function clearMap() {
|
|
105
134
|
markedFeatures = [];
|
|
106
135
|
picked = undefined;
|
|
107
136
|
}
|
|
108
|
-
let focused = false;
|
|
109
137
|
let listFeatures;
|
|
110
138
|
let markedFeatures;
|
|
111
139
|
let picked;
|
|
@@ -118,11 +146,10 @@ let abortController;
|
|
|
118
146
|
let searchTimeoutRef;
|
|
119
147
|
let focusedDelayed;
|
|
120
148
|
let prevIdToFly;
|
|
149
|
+
let focused = false;
|
|
121
150
|
const missingIconsCache = new Set();
|
|
122
151
|
const dispatch = createEventDispatcher();
|
|
123
|
-
$:
|
|
124
|
-
reverseActive = enableReverse === "always";
|
|
125
|
-
}
|
|
152
|
+
$: reverseActive = enableReverse === "always";
|
|
126
153
|
$: if (pickedResultStyle !== "marker-only" &&
|
|
127
154
|
picked &&
|
|
128
155
|
!picked.address &&
|
|
@@ -132,14 +159,10 @@ $: if (pickedResultStyle !== "marker-only" &&
|
|
|
132
159
|
}
|
|
133
160
|
$: {
|
|
134
161
|
if (mapController && picked && picked.id !== prevIdToFly && flyTo) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
mapController.fitBounds(unwrapBbox(picked.bbox), 50, computeZoom(picked));
|
|
162
|
+
goToPicked();
|
|
163
|
+
if (clearListOnPick) {
|
|
164
|
+
listFeatures = undefined;
|
|
141
165
|
}
|
|
142
|
-
listFeatures = undefined;
|
|
143
166
|
markedFeatures = undefined;
|
|
144
167
|
selectedItemIndex = -1;
|
|
145
168
|
}
|
|
@@ -155,7 +178,7 @@ $: if (!markerOnSelected) {
|
|
|
155
178
|
mapController?.setFeatures(undefined, undefined, showPolygonMarker);
|
|
156
179
|
}
|
|
157
180
|
$: if (mapController && markerOnSelected && !markedFeatures) {
|
|
158
|
-
mapController.setFeatures(selected ? [selected] : undefined,
|
|
181
|
+
mapController.setFeatures(selected ? [selected] : undefined, picked, showPolygonMarker);
|
|
159
182
|
mapController.setSelectedMarker(selected ? 0 : -1);
|
|
160
183
|
}
|
|
161
184
|
$: if (markedFeatures !== listFeatures) {
|
|
@@ -165,7 +188,6 @@ $: if (mapController) {
|
|
|
165
188
|
mapController.setFeatures(markedFeatures, picked, showPolygonMarker);
|
|
166
189
|
}
|
|
167
190
|
$: if (searchValue.length < minLength) {
|
|
168
|
-
picked = undefined;
|
|
169
191
|
listFeatures = undefined;
|
|
170
192
|
error = undefined;
|
|
171
193
|
markedFeatures = listFeatures;
|
|
@@ -177,19 +199,16 @@ $: if (markedFeatures && mapController) {
|
|
|
177
199
|
// close dropdown in the next cycle so that the selected item event has the chance to fire
|
|
178
200
|
$: setTimeout(() => {
|
|
179
201
|
focusedDelayed = focused;
|
|
180
|
-
if (clearOnBlur && !
|
|
202
|
+
if (clearOnBlur && !focusedDelayed) {
|
|
181
203
|
searchValue = "";
|
|
182
204
|
}
|
|
183
205
|
});
|
|
184
|
-
$: if (selectFirst &&
|
|
206
|
+
$: if (selectFirst &&
|
|
207
|
+
listFeatures?.length &&
|
|
208
|
+
selectedItemIndex == -1 &&
|
|
209
|
+
!picked) {
|
|
185
210
|
selectedItemIndex = 0;
|
|
186
211
|
}
|
|
187
|
-
// clear selection on edit
|
|
188
|
-
$: {
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
190
|
-
searchValue;
|
|
191
|
-
selectedItemIndex = -1;
|
|
192
|
-
}
|
|
193
212
|
$: selected = listFeatures?.[selectedItemIndex];
|
|
194
213
|
$: if (mapController) {
|
|
195
214
|
const coords = isQueryReverse(searchValue);
|
|
@@ -197,9 +216,9 @@ $: if (mapController) {
|
|
|
197
216
|
}
|
|
198
217
|
$: dispatch("select", { feature: selected });
|
|
199
218
|
$: dispatch("pick", { feature: picked });
|
|
200
|
-
$:
|
|
201
|
-
|
|
202
|
-
});
|
|
219
|
+
$: optionsVisible =
|
|
220
|
+
!!listFeatures?.length && (focusedDelayed || keepListOpen);
|
|
221
|
+
$: dispatch("optionsvisibilitychange", { optionsVisible });
|
|
203
222
|
$: dispatch("featureslisted", { features: listFeatures });
|
|
204
223
|
$: dispatch("featuresmarked", { features: markedFeatures });
|
|
205
224
|
$: dispatch("reversetoggle", { reverse: reverseActive });
|
|
@@ -247,7 +266,8 @@ onDestroy(() => {
|
|
|
247
266
|
mapController.setFeatures(undefined, undefined, false);
|
|
248
267
|
}
|
|
249
268
|
});
|
|
250
|
-
function
|
|
269
|
+
function handleSubmit(event) {
|
|
270
|
+
focused = false;
|
|
251
271
|
if (searchTimeoutRef) {
|
|
252
272
|
clearTimeout(searchTimeoutRef);
|
|
253
273
|
searchTimeoutRef = undefined;
|
|
@@ -290,7 +310,13 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
290
310
|
abortController = ac;
|
|
291
311
|
try {
|
|
292
312
|
const isReverse = isQueryReverse(searchValue);
|
|
293
|
-
const
|
|
313
|
+
const urlObj = new URL(apiUrl +
|
|
314
|
+
"/" +
|
|
315
|
+
encodeURIComponent(isReverse
|
|
316
|
+
? isReverse.decimalLongitude + "," + isReverse.decimalLatitude
|
|
317
|
+
: searchValue) +
|
|
318
|
+
".json");
|
|
319
|
+
const sp = urlObj.searchParams;
|
|
294
320
|
if (language !== undefined) {
|
|
295
321
|
sp.set("language", Array.isArray(language) ? language.join(",") : (language ?? ""));
|
|
296
322
|
}
|
|
@@ -322,20 +348,20 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
322
348
|
}
|
|
323
349
|
sp.set("key", apiKey);
|
|
324
350
|
adjustUrlQuery(sp);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
encodeURIComponent(isReverse
|
|
328
|
-
? isReverse.decimalLongitude + "," + isReverse.decimalLatitude
|
|
329
|
-
: searchValue) +
|
|
330
|
-
".json?" +
|
|
331
|
-
sp.toString();
|
|
351
|
+
adjustUrl(urlObj);
|
|
352
|
+
const url = urlObj.toString();
|
|
332
353
|
if (url === lastSearchUrl) {
|
|
333
354
|
if (byId) {
|
|
334
|
-
|
|
355
|
+
if (clearListOnPick) {
|
|
356
|
+
listFeatures = undefined;
|
|
357
|
+
}
|
|
335
358
|
picked = cachedFeatures[0];
|
|
336
359
|
}
|
|
337
360
|
else {
|
|
338
361
|
listFeatures = cachedFeatures;
|
|
362
|
+
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
363
|
+
selectedItemIndex = -1;
|
|
364
|
+
}
|
|
339
365
|
}
|
|
340
366
|
return;
|
|
341
367
|
}
|
|
@@ -350,7 +376,9 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
350
376
|
const featureCollection = await res.json();
|
|
351
377
|
dispatch("response", { url, featureCollection });
|
|
352
378
|
if (byId) {
|
|
353
|
-
|
|
379
|
+
if (clearListOnPick) {
|
|
380
|
+
listFeatures = undefined;
|
|
381
|
+
}
|
|
354
382
|
picked = featureCollection.features[0];
|
|
355
383
|
cachedFeatures = [picked];
|
|
356
384
|
}
|
|
@@ -384,6 +412,9 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
384
412
|
});
|
|
385
413
|
}
|
|
386
414
|
cachedFeatures = listFeatures;
|
|
415
|
+
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
416
|
+
selectedItemIndex = -1;
|
|
417
|
+
}
|
|
387
418
|
if (isReverse) {
|
|
388
419
|
input.focus();
|
|
389
420
|
}
|
|
@@ -434,6 +465,18 @@ function zoomToResults() {
|
|
|
434
465
|
}
|
|
435
466
|
}
|
|
436
467
|
}
|
|
468
|
+
function goToPicked() {
|
|
469
|
+
if (!picked || !mapController) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (!picked.bbox ||
|
|
473
|
+
(picked.bbox[0] === picked.bbox[2] && picked.bbox[1] === picked.bbox[3])) {
|
|
474
|
+
mapController.flyTo(picked.center, computeZoom(picked));
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
mapController.fitBounds(unwrapBbox(picked.bbox), 50, computeZoom(picked));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
437
480
|
function computeZoom(feature) {
|
|
438
481
|
if (!feature.bbox ||
|
|
439
482
|
(feature.bbox[0] !== feature.bbox[2] &&
|
|
@@ -462,22 +505,30 @@ function handleKeyDown(e) {
|
|
|
462
505
|
return;
|
|
463
506
|
}
|
|
464
507
|
let dir = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
|
|
465
|
-
if (dir) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
508
|
+
if (!dir) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
input.focus();
|
|
512
|
+
focused = true;
|
|
513
|
+
e.preventDefault();
|
|
514
|
+
if (picked && selectedItemIndex === -1) {
|
|
515
|
+
selectedItemIndex = listFeatures.findIndex((listFeature) => listFeature.id === picked?.id);
|
|
516
|
+
}
|
|
517
|
+
if (selectedItemIndex === (picked || selectFirst ? 0 : -1) && dir === -1) {
|
|
518
|
+
selectedItemIndex = listFeatures.length;
|
|
519
|
+
}
|
|
520
|
+
selectedItemIndex += dir;
|
|
521
|
+
if (selectedItemIndex >= listFeatures.length) {
|
|
522
|
+
selectedItemIndex = -1;
|
|
523
|
+
}
|
|
524
|
+
if (selectedItemIndex < 0 && (picked || selectFirst)) {
|
|
525
|
+
selectedItemIndex = 0;
|
|
477
526
|
}
|
|
478
527
|
}
|
|
479
|
-
function handleInput(debounce = true, reverse = false) {
|
|
528
|
+
function handleInput(_, debounce = true, reverse = false) {
|
|
480
529
|
error = undefined;
|
|
530
|
+
picked = undefined;
|
|
531
|
+
focused = true;
|
|
481
532
|
if (showResultsWhileTyping || reverse) {
|
|
482
533
|
if (searchTimeoutRef) {
|
|
483
534
|
clearTimeout(searchTimeoutRef);
|
|
@@ -496,9 +547,25 @@ function handleInput(debounce = true, reverse = false) {
|
|
|
496
547
|
}
|
|
497
548
|
}
|
|
498
549
|
function pick(feature) {
|
|
499
|
-
picked
|
|
500
|
-
|
|
501
|
-
|
|
550
|
+
if (picked && picked?.id === feature?.id) {
|
|
551
|
+
goToPicked();
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
picked = feature;
|
|
555
|
+
searchValue = feature.place_name;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function handleMouseEnter(index) {
|
|
559
|
+
selectedItemIndex = index;
|
|
560
|
+
}
|
|
561
|
+
function handleMouseLeave() {
|
|
562
|
+
if (!selectFirst || picked) {
|
|
563
|
+
selectedItemIndex = -1;
|
|
564
|
+
}
|
|
565
|
+
// re-focus on picked
|
|
566
|
+
if (flyToSelected) {
|
|
567
|
+
goToPicked();
|
|
568
|
+
}
|
|
502
569
|
}
|
|
503
570
|
</script>
|
|
504
571
|
|
|
@@ -507,10 +574,8 @@ function pick(feature) {
|
|
|
507
574
|
<MarkerIcon displayIn="list" />
|
|
508
575
|
{/if}
|
|
509
576
|
|
|
510
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
511
577
|
<form
|
|
512
|
-
|
|
513
|
-
on:submit|preventDefault={handleOnSubmit}
|
|
578
|
+
on:submit|preventDefault={handleSubmit}
|
|
514
579
|
class:can-collapse={collapsed && searchValue === ""}
|
|
515
580
|
class={className}
|
|
516
581
|
>
|
|
@@ -524,8 +589,10 @@ function pick(feature) {
|
|
|
524
589
|
bind:value={searchValue}
|
|
525
590
|
on:focus={() => (focused = true)}
|
|
526
591
|
on:blur={() => (focused = false)}
|
|
592
|
+
on:click={() => (focused = true)}
|
|
527
593
|
on:keydown={handleKeyDown}
|
|
528
|
-
on:input={
|
|
594
|
+
on:input={handleInput}
|
|
595
|
+
on:change={() => (picked = undefined)}
|
|
529
596
|
{placeholder}
|
|
530
597
|
aria-label={placeholder}
|
|
531
598
|
/>
|
|
@@ -571,7 +638,7 @@ function pick(feature) {
|
|
|
571
638
|
<ClearIcon />
|
|
572
639
|
</button>
|
|
573
640
|
</div>
|
|
574
|
-
{:else if !focusedDelayed}
|
|
641
|
+
{:else if !focusedDelayed && !keepListOpen}
|
|
575
642
|
{""}
|
|
576
643
|
{:else if listFeatures?.length === 0}
|
|
577
644
|
<div class="no-results">
|
|
@@ -579,23 +646,25 @@ function pick(feature) {
|
|
|
579
646
|
|
|
580
647
|
<div>{noResultsMessage}</div>
|
|
581
648
|
</div>
|
|
582
|
-
{:else if
|
|
649
|
+
{:else if listFeatures?.length && (focusedDelayed || keepListOpen)}
|
|
583
650
|
<ul
|
|
584
651
|
class="options"
|
|
585
|
-
on:mouseleave={
|
|
586
|
-
if (!selectFirst) {
|
|
587
|
-
selectedItemIndex = -1;
|
|
588
|
-
}
|
|
589
|
-
}}
|
|
652
|
+
on:mouseleave={handleMouseLeave}
|
|
590
653
|
on:blur={() => undefined}
|
|
654
|
+
on:keydown={handleKeyDown}
|
|
655
|
+
role="listbox"
|
|
591
656
|
>
|
|
592
657
|
{#each listFeatures as feature, i (feature.id + (feature.address ? "," + feature.address : ""))}
|
|
593
658
|
<FeatureItem
|
|
594
659
|
{feature}
|
|
595
660
|
{showPlaceType}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
661
|
+
style={selectedItemIndex === i
|
|
662
|
+
? "selected"
|
|
663
|
+
: picked?.id === feature.id
|
|
664
|
+
? "picked"
|
|
665
|
+
: "default"}
|
|
666
|
+
on:mouseenter={() => handleMouseEnter(i)}
|
|
667
|
+
on:select={() => pick(feature)}
|
|
599
668
|
{missingIconsCache}
|
|
600
669
|
{iconsBaseUrl}
|
|
601
670
|
/>
|
|
@@ -8,6 +8,8 @@ declare const __propDef: {
|
|
|
8
8
|
bbox?: BBox | undefined;
|
|
9
9
|
clearButtonTitle?: string;
|
|
10
10
|
clearOnBlur?: boolean;
|
|
11
|
+
clearListOnPick?: boolean;
|
|
12
|
+
keepListOpen?: boolean;
|
|
11
13
|
collapsed?: boolean;
|
|
12
14
|
country?: string | string[] | undefined;
|
|
13
15
|
debounceSearch?: number;
|
|
@@ -39,8 +41,13 @@ declare const __propDef: {
|
|
|
39
41
|
apiUrl?: string;
|
|
40
42
|
fetchParameters?: RequestInit;
|
|
41
43
|
iconsBaseUrl?: string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated use `adjustUrl`
|
|
46
|
+
*/ adjustUrlQuery?: (sp: URLSearchParams) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Adjust geocoding URL before the fetch.
|
|
49
|
+
*/ adjustUrl?: (url: URL) => void;
|
|
50
|
+
focus?: (options?: FocusOptions) => void;
|
|
44
51
|
blur?: () => void;
|
|
45
52
|
setQuery?: (value: string, submit?: boolean, reverse?: boolean) => void;
|
|
46
53
|
clearList?: () => void;
|
|
@@ -86,7 +93,7 @@ export type GeocodingControlEvents = typeof __propDef.events;
|
|
|
86
93
|
export type GeocodingControlSlots = typeof __propDef.slots;
|
|
87
94
|
export default class GeocodingControl extends SvelteComponent<GeocodingControlProps, GeocodingControlEvents, GeocodingControlSlots> {
|
|
88
95
|
get ZOOM_DEFAULTS(): Record<string, number>;
|
|
89
|
-
get focus(): () => void;
|
|
96
|
+
get focus(): (options?: FocusOptions) => void;
|
|
90
97
|
get blur(): () => void;
|
|
91
98
|
get setQuery(): (value: string, submit?: boolean, reverse?: boolean) => void;
|
|
92
99
|
get clearList(): () => void;
|