@maptiler/geocoding-control 2.0.0 → 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 +3027 -27
- 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.d.ts +1 -1
- package/leaflet-controller.js +113 -110
- 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 +58 -5
- package/leaflet.js +1438 -1265
- 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 +483 -469
- 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 +2499 -13
- package/maplibregl.js +2435 -2139
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.d.ts +2499 -13
- package/maptilersdk.js +2432 -2139
- 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 +66 -63
- 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 +53 -1
- package/openlayers.js +2046 -1902
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +3 -3
- package/openlayers.umd.js.map +1 -1
- package/package.json +28 -28
- package/react.d.ts +31 -5
- package/react.js +1252 -1096
- 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 +60 -13
- package/svelte/FeatureItem.svelte.d.ts +4 -4
- package/svelte/GeocodingControl.svelte +166 -98
- package/svelte/GeocodingControl.svelte.d.ts +36 -16
- package/svelte/MapLibreBasedGeocodingControl.d.ts +3027 -27
- package/svelte/MapLibreBasedGeocodingControl.js +154 -21
- package/svelte/leaflet-controller.d.ts +1 -1
- package/svelte/leaflet-controller.js +6 -3
- package/svelte/leaflet.d.ts +58 -5
- package/svelte/leaflet.js +52 -21
- package/svelte/maplibregl-controller.d.ts +1 -1
- package/svelte/maplibregl-controller.js +47 -38
- package/svelte/maplibregl.d.ts +2499 -13
- package/svelte/maplibregl.js +11 -3
- package/svelte/maptilersdk.d.ts +2499 -13
- package/svelte/maptilersdk.js +11 -3
- package/svelte/openlayers-controller.d.ts +1 -1
- package/svelte/openlayers-controller.js +7 -4
- package/svelte/openlayers.d.ts +53 -1
- package/svelte/openlayers.js +66 -48
- package/svelte/react.d.ts +31 -5
- package/svelte/react.js +21 -9
- package/svelte/types.d.ts +106 -35
- package/svelte/vanilla.d.ts +46 -2
- package/svelte/vanilla.js +66 -10
- package/types.d.ts +106 -35
- package/vanilla.d.ts +46 -2
- package/vanilla.js +1260 -1057
- 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">
|
|
@@ -58,7 +87,7 @@ function handleImgError() {
|
|
|
58
87
|
{isReverse ? feature.place_name : feature.place_name.replace(/,.*/, "")}
|
|
59
88
|
</span>
|
|
60
89
|
|
|
61
|
-
{#if showPlaceType === "always" || (showPlaceType && !feature.address && !feature.id.startsWith("road.") && !feature.id.startsWith("address.") && !feature.id.startsWith("postal_code.") && (!feature.id.startsWith("poi.") || !imageUrl) && !isReverse)}
|
|
90
|
+
{#if showPlaceType === "always" || (showPlaceType !== "never" && !feature.address && !feature.id.startsWith("road.") && !feature.id.startsWith("address.") && !feature.id.startsWith("postal_code.") && (!feature.id.startsWith("poi.") || !imageUrl) && !isReverse)}
|
|
62
91
|
<span class="secondary">
|
|
63
92
|
{placeType}
|
|
64
93
|
</span>
|
|
@@ -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;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Feature } from "./types";
|
|
2
|
+
import type { Feature, ShowPlaceType } from "./types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
feature: Feature;
|
|
6
|
-
|
|
7
|
-
showPlaceType:
|
|
6
|
+
style?: "selected" | "picked" | "default";
|
|
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,10 +40,12 @@ 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;
|
|
46
|
-
export let enableReverse =
|
|
48
|
+
export let enableReverse = "never";
|
|
47
49
|
export let errorMessage = "Something went wrong…";
|
|
48
50
|
export let filter = () => true;
|
|
49
51
|
export let flyTo = true;
|
|
@@ -60,8 +62,8 @@ export let proximity = [
|
|
|
60
62
|
export let reverseActive = enableReverse === "always";
|
|
61
63
|
export let reverseButtonTitle = "toggle reverse geocoding";
|
|
62
64
|
export let searchValue = "";
|
|
63
|
-
export let
|
|
64
|
-
export let showPlaceType = "
|
|
65
|
+
export let pickedResultStyle = "full-geometry";
|
|
66
|
+
export let showPlaceType = "if-needed";
|
|
65
67
|
export let showResultsWhileTyping = true;
|
|
66
68
|
export let selectFirst = true;
|
|
67
69
|
export let flyToSelected = false;
|
|
@@ -70,43 +72,68 @@ export let types = undefined;
|
|
|
70
72
|
export let exhaustiveReverseGeocoding = false;
|
|
71
73
|
export let excludeTypes = false;
|
|
72
74
|
export let zoom = ZOOM_DEFAULTS;
|
|
73
|
-
export let maxZoom = undefined;
|
|
74
75
|
export let apiUrl = "https://api.maptiler.com/geocoding";
|
|
75
76
|
export let fetchParameters = {};
|
|
76
77
|
export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
|
|
77
|
-
"2.
|
|
78
|
+
"2.1.0-rc1" +
|
|
78
79
|
"/icons/";
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated use `adjustUrl`
|
|
82
|
+
*/
|
|
79
83
|
export let adjustUrlQuery = () => { };
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
*/
|
|
83
99
|
export function blur() {
|
|
84
100
|
input.blur();
|
|
85
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Set the content of search input box.
|
|
104
|
+
*
|
|
105
|
+
* @param value text to set
|
|
106
|
+
* @param submit perform the search
|
|
107
|
+
*/
|
|
86
108
|
export function setQuery(value, submit = true, reverse = false) {
|
|
87
109
|
searchValue = value;
|
|
88
110
|
if (submit) {
|
|
89
111
|
selectedItemIndex = -1;
|
|
90
|
-
|
|
112
|
+
handleSubmit();
|
|
91
113
|
}
|
|
92
114
|
else {
|
|
93
|
-
handleInput(!reverse, reverse);
|
|
115
|
+
handleInput(undefined, !reverse, reverse);
|
|
94
116
|
setTimeout(() => {
|
|
95
117
|
input.focus();
|
|
96
118
|
input.select();
|
|
97
119
|
});
|
|
98
120
|
}
|
|
99
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Clear search result list.
|
|
124
|
+
*/
|
|
100
125
|
export function clearList() {
|
|
101
126
|
listFeatures = undefined;
|
|
102
127
|
picked = undefined;
|
|
103
128
|
selectedItemIndex = -1;
|
|
104
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Clear geocoding search results from the map.
|
|
132
|
+
*/
|
|
105
133
|
export function clearMap() {
|
|
106
134
|
markedFeatures = [];
|
|
107
135
|
picked = undefined;
|
|
108
136
|
}
|
|
109
|
-
let focused = false;
|
|
110
137
|
let listFeatures;
|
|
111
138
|
let markedFeatures;
|
|
112
139
|
let picked;
|
|
@@ -119,12 +146,11 @@ let abortController;
|
|
|
119
146
|
let searchTimeoutRef;
|
|
120
147
|
let focusedDelayed;
|
|
121
148
|
let prevIdToFly;
|
|
149
|
+
let focused = false;
|
|
122
150
|
const missingIconsCache = new Set();
|
|
123
151
|
const dispatch = createEventDispatcher();
|
|
124
|
-
$:
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
$: if (showFullGeometry &&
|
|
152
|
+
$: reverseActive = enableReverse === "always";
|
|
153
|
+
$: if (pickedResultStyle !== "marker-only" &&
|
|
128
154
|
picked &&
|
|
129
155
|
!picked.address &&
|
|
130
156
|
picked.geometry.type === "Point" &&
|
|
@@ -133,14 +159,10 @@ $: if (showFullGeometry &&
|
|
|
133
159
|
}
|
|
134
160
|
$: {
|
|
135
161
|
if (mapController && picked && picked.id !== prevIdToFly && flyTo) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
mapController.fitBounds(unwrapBbox(picked.bbox), 50, computeZoom(picked));
|
|
162
|
+
goToPicked();
|
|
163
|
+
if (clearListOnPick) {
|
|
164
|
+
listFeatures = undefined;
|
|
142
165
|
}
|
|
143
|
-
listFeatures = undefined;
|
|
144
166
|
markedFeatures = undefined;
|
|
145
167
|
selectedItemIndex = -1;
|
|
146
168
|
}
|
|
@@ -149,22 +171,23 @@ $: {
|
|
|
149
171
|
$: if (mapController && selected && flyTo && flyToSelected) {
|
|
150
172
|
mapController.flyTo(selected.center, computeZoom(selected));
|
|
151
173
|
}
|
|
174
|
+
$: showPolygonMarker =
|
|
175
|
+
pickedResultStyle === "full-geometry-including-polygon-center-marker";
|
|
152
176
|
// if markerOnSelected was dynamically changed to false
|
|
153
177
|
$: if (!markerOnSelected) {
|
|
154
|
-
mapController?.
|
|
178
|
+
mapController?.setFeatures(undefined, undefined, showPolygonMarker);
|
|
155
179
|
}
|
|
156
180
|
$: if (mapController && markerOnSelected && !markedFeatures) {
|
|
157
|
-
mapController.
|
|
181
|
+
mapController.setFeatures(selected ? [selected] : undefined, picked, showPolygonMarker);
|
|
158
182
|
mapController.setSelectedMarker(selected ? 0 : -1);
|
|
159
183
|
}
|
|
160
184
|
$: if (markedFeatures !== listFeatures) {
|
|
161
185
|
markedFeatures = undefined;
|
|
162
186
|
}
|
|
163
187
|
$: if (mapController) {
|
|
164
|
-
mapController.
|
|
188
|
+
mapController.setFeatures(markedFeatures, picked, showPolygonMarker);
|
|
165
189
|
}
|
|
166
190
|
$: if (searchValue.length < minLength) {
|
|
167
|
-
picked = undefined;
|
|
168
191
|
listFeatures = undefined;
|
|
169
192
|
error = undefined;
|
|
170
193
|
markedFeatures = listFeatures;
|
|
@@ -176,31 +199,30 @@ $: if (markedFeatures && mapController) {
|
|
|
176
199
|
// close dropdown in the next cycle so that the selected item event has the chance to fire
|
|
177
200
|
$: setTimeout(() => {
|
|
178
201
|
focusedDelayed = focused;
|
|
179
|
-
if (clearOnBlur && !
|
|
202
|
+
if (clearOnBlur && !focusedDelayed) {
|
|
180
203
|
searchValue = "";
|
|
181
204
|
}
|
|
182
205
|
});
|
|
183
|
-
$: if (selectFirst &&
|
|
206
|
+
$: if (selectFirst &&
|
|
207
|
+
listFeatures?.length &&
|
|
208
|
+
selectedItemIndex == -1 &&
|
|
209
|
+
!picked) {
|
|
184
210
|
selectedItemIndex = 0;
|
|
185
211
|
}
|
|
186
|
-
// clear selection on edit
|
|
187
|
-
$: {
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
189
|
-
searchValue;
|
|
190
|
-
selectedItemIndex = -1;
|
|
191
|
-
}
|
|
192
212
|
$: selected = listFeatures?.[selectedItemIndex];
|
|
193
213
|
$: if (mapController) {
|
|
194
214
|
const coords = isQueryReverse(searchValue);
|
|
195
215
|
mapController.setReverseMarker(coords ? [coords.decimalLongitude, coords.decimalLatitude] : undefined);
|
|
196
216
|
}
|
|
197
|
-
$: dispatch("select", selected);
|
|
198
|
-
$: dispatch("pick", picked);
|
|
199
|
-
$:
|
|
200
|
-
|
|
201
|
-
$: dispatch("
|
|
202
|
-
$: dispatch("
|
|
203
|
-
$: dispatch("
|
|
217
|
+
$: dispatch("select", { feature: selected });
|
|
218
|
+
$: dispatch("pick", { feature: picked });
|
|
219
|
+
$: optionsVisible =
|
|
220
|
+
!!listFeatures?.length && (focusedDelayed || keepListOpen);
|
|
221
|
+
$: dispatch("optionsvisibilitychange", { optionsVisible });
|
|
222
|
+
$: dispatch("featureslisted", { features: listFeatures });
|
|
223
|
+
$: dispatch("featuresmarked", { features: markedFeatures });
|
|
224
|
+
$: dispatch("reversetoggle", { reverse: reverseActive });
|
|
225
|
+
$: dispatch("querychange", { query: searchValue });
|
|
204
226
|
$: if (mapController) {
|
|
205
227
|
mapController.indicateReverse(reverseActive);
|
|
206
228
|
}
|
|
@@ -241,10 +263,11 @@ onDestroy(() => {
|
|
|
241
263
|
mapController.setEventHandler(undefined);
|
|
242
264
|
mapController.indicateReverse(false);
|
|
243
265
|
mapController.setSelectedMarker(-1);
|
|
244
|
-
mapController.
|
|
266
|
+
mapController.setFeatures(undefined, undefined, false);
|
|
245
267
|
}
|
|
246
268
|
});
|
|
247
|
-
function
|
|
269
|
+
function handleSubmit(event) {
|
|
270
|
+
focused = false;
|
|
248
271
|
if (searchTimeoutRef) {
|
|
249
272
|
clearTimeout(searchTimeoutRef);
|
|
250
273
|
searchTimeoutRef = undefined;
|
|
@@ -287,7 +310,13 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
287
310
|
abortController = ac;
|
|
288
311
|
try {
|
|
289
312
|
const isReverse = isQueryReverse(searchValue);
|
|
290
|
-
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;
|
|
291
320
|
if (language !== undefined) {
|
|
292
321
|
sp.set("language", Array.isArray(language) ? language.join(",") : (language ?? ""));
|
|
293
322
|
}
|
|
@@ -319,20 +348,20 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
319
348
|
}
|
|
320
349
|
sp.set("key", apiKey);
|
|
321
350
|
adjustUrlQuery(sp);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
encodeURIComponent(isReverse
|
|
325
|
-
? isReverse.decimalLongitude + "," + isReverse.decimalLatitude
|
|
326
|
-
: searchValue) +
|
|
327
|
-
".json?" +
|
|
328
|
-
sp.toString();
|
|
351
|
+
adjustUrl(urlObj);
|
|
352
|
+
const url = urlObj.toString();
|
|
329
353
|
if (url === lastSearchUrl) {
|
|
330
354
|
if (byId) {
|
|
331
|
-
|
|
355
|
+
if (clearListOnPick) {
|
|
356
|
+
listFeatures = undefined;
|
|
357
|
+
}
|
|
332
358
|
picked = cachedFeatures[0];
|
|
333
359
|
}
|
|
334
360
|
else {
|
|
335
361
|
listFeatures = cachedFeatures;
|
|
362
|
+
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
363
|
+
selectedItemIndex = -1;
|
|
364
|
+
}
|
|
336
365
|
}
|
|
337
366
|
return;
|
|
338
367
|
}
|
|
@@ -347,7 +376,9 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
347
376
|
const featureCollection = await res.json();
|
|
348
377
|
dispatch("response", { url, featureCollection });
|
|
349
378
|
if (byId) {
|
|
350
|
-
|
|
379
|
+
if (clearListOnPick) {
|
|
380
|
+
listFeatures = undefined;
|
|
381
|
+
}
|
|
351
382
|
picked = featureCollection.features[0];
|
|
352
383
|
cachedFeatures = [picked];
|
|
353
384
|
}
|
|
@@ -381,6 +412,9 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
|
381
412
|
});
|
|
382
413
|
}
|
|
383
414
|
cachedFeatures = listFeatures;
|
|
415
|
+
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
416
|
+
selectedItemIndex = -1;
|
|
417
|
+
}
|
|
384
418
|
if (isReverse) {
|
|
385
419
|
input.focus();
|
|
386
420
|
}
|
|
@@ -411,12 +445,11 @@ function zoomToResults() {
|
|
|
411
445
|
for (const feature of markedFeatures) {
|
|
412
446
|
const featZoom = computeZoom(feature);
|
|
413
447
|
allZoom =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
: Math.max(allZoom, featZoom));
|
|
448
|
+
allZoom === undefined
|
|
449
|
+
? featZoom
|
|
450
|
+
: featZoom === undefined
|
|
451
|
+
? allZoom
|
|
452
|
+
: Math.max(allZoom, featZoom);
|
|
420
453
|
if (fuzzyOnly || !feature.matching_text) {
|
|
421
454
|
for (const i of [0, 1, 2, 3]) {
|
|
422
455
|
bbox[i] = Math[i < 2 ? "min" : "max"](bbox[i], feature.bbox?.[i] ?? feature.center[i % 2]);
|
|
@@ -432,17 +465,24 @@ function zoomToResults() {
|
|
|
432
465
|
}
|
|
433
466
|
}
|
|
434
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
|
+
}
|
|
435
480
|
function computeZoom(feature) {
|
|
436
481
|
if (!feature.bbox ||
|
|
437
482
|
(feature.bbox[0] !== feature.bbox[2] &&
|
|
438
483
|
feature.bbox[1] !== feature.bbox[3])) {
|
|
439
484
|
return undefined;
|
|
440
485
|
}
|
|
441
|
-
if (typeof zoom === "number") {
|
|
442
|
-
return feature.id.startsWith("poi.") || feature.id.startsWith("address.")
|
|
443
|
-
? maxZoom
|
|
444
|
-
: zoom;
|
|
445
|
-
}
|
|
446
486
|
const index = feature.id.replace(/\..*/, "");
|
|
447
487
|
return ((Array.isArray(feature.properties?.categories)
|
|
448
488
|
? feature.properties.categories.reduce((a, category) => {
|
|
@@ -465,22 +505,30 @@ function handleKeyDown(e) {
|
|
|
465
505
|
return;
|
|
466
506
|
}
|
|
467
507
|
let dir = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
|
|
468
|
-
if (dir) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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;
|
|
480
526
|
}
|
|
481
527
|
}
|
|
482
|
-
function handleInput(debounce = true, reverse = false) {
|
|
528
|
+
function handleInput(_, debounce = true, reverse = false) {
|
|
483
529
|
error = undefined;
|
|
530
|
+
picked = undefined;
|
|
531
|
+
focused = true;
|
|
484
532
|
if (showResultsWhileTyping || reverse) {
|
|
485
533
|
if (searchTimeoutRef) {
|
|
486
534
|
clearTimeout(searchTimeoutRef);
|
|
@@ -499,9 +547,25 @@ function handleInput(debounce = true, reverse = false) {
|
|
|
499
547
|
}
|
|
500
548
|
}
|
|
501
549
|
function pick(feature) {
|
|
502
|
-
picked
|
|
503
|
-
|
|
504
|
-
|
|
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
|
+
}
|
|
505
569
|
}
|
|
506
570
|
</script>
|
|
507
571
|
|
|
@@ -510,10 +574,8 @@ function pick(feature) {
|
|
|
510
574
|
<MarkerIcon displayIn="list" />
|
|
511
575
|
{/if}
|
|
512
576
|
|
|
513
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
514
577
|
<form
|
|
515
|
-
|
|
516
|
-
on:submit|preventDefault={handleOnSubmit}
|
|
578
|
+
on:submit|preventDefault={handleSubmit}
|
|
517
579
|
class:can-collapse={collapsed && searchValue === ""}
|
|
518
580
|
class={className}
|
|
519
581
|
>
|
|
@@ -527,8 +589,10 @@ function pick(feature) {
|
|
|
527
589
|
bind:value={searchValue}
|
|
528
590
|
on:focus={() => (focused = true)}
|
|
529
591
|
on:blur={() => (focused = false)}
|
|
592
|
+
on:click={() => (focused = true)}
|
|
530
593
|
on:keydown={handleKeyDown}
|
|
531
|
-
on:input={
|
|
594
|
+
on:input={handleInput}
|
|
595
|
+
on:change={() => (picked = undefined)}
|
|
532
596
|
{placeholder}
|
|
533
597
|
aria-label={placeholder}
|
|
534
598
|
/>
|
|
@@ -550,7 +614,7 @@ function pick(feature) {
|
|
|
550
614
|
{/if}
|
|
551
615
|
</div>
|
|
552
616
|
|
|
553
|
-
{#if enableReverse ===
|
|
617
|
+
{#if enableReverse === "button"}
|
|
554
618
|
<button
|
|
555
619
|
type="button"
|
|
556
620
|
class:active={reverseActive}
|
|
@@ -574,7 +638,7 @@ function pick(feature) {
|
|
|
574
638
|
<ClearIcon />
|
|
575
639
|
</button>
|
|
576
640
|
</div>
|
|
577
|
-
{:else if !focusedDelayed}
|
|
641
|
+
{:else if !focusedDelayed && !keepListOpen}
|
|
578
642
|
{""}
|
|
579
643
|
{:else if listFeatures?.length === 0}
|
|
580
644
|
<div class="no-results">
|
|
@@ -582,22 +646,25 @@ function pick(feature) {
|
|
|
582
646
|
|
|
583
647
|
<div>{noResultsMessage}</div>
|
|
584
648
|
</div>
|
|
585
|
-
{:else if
|
|
649
|
+
{:else if listFeatures?.length && (focusedDelayed || keepListOpen)}
|
|
586
650
|
<ul
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
selectedItemIndex = -1;
|
|
590
|
-
}
|
|
591
|
-
}}
|
|
651
|
+
class="options"
|
|
652
|
+
on:mouseleave={handleMouseLeave}
|
|
592
653
|
on:blur={() => undefined}
|
|
654
|
+
on:keydown={handleKeyDown}
|
|
655
|
+
role="listbox"
|
|
593
656
|
>
|
|
594
657
|
{#each listFeatures as feature, i (feature.id + (feature.address ? "," + feature.address : ""))}
|
|
595
658
|
<FeatureItem
|
|
596
659
|
{feature}
|
|
597
660
|
{showPlaceType}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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)}
|
|
601
668
|
{missingIconsCache}
|
|
602
669
|
{iconsBaseUrl}
|
|
603
670
|
/>
|
|
@@ -726,10 +793,11 @@ div.no-results :global(svg) {
|
|
|
726
793
|
height: 30px;
|
|
727
794
|
}
|
|
728
795
|
|
|
729
|
-
:global(.
|
|
730
|
-
:global(.maplibregl-ctrl-bottom-
|
|
796
|
+
:global(.leaflet-bottom) ul.options,
|
|
797
|
+
:global(.maplibregl-ctrl-bottom-left) ul.options,
|
|
798
|
+
:global(.maplibregl-ctrl-bottom-right) ul.options {
|
|
731
799
|
top: auto;
|
|
732
|
-
bottom: 100
|
|
800
|
+
bottom: calc(100% + 6px);
|
|
733
801
|
}
|
|
734
802
|
|
|
735
803
|
button {
|