@maptiler/geocoding-control 2.1.6 → 3.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +46 -0
- package/CONTRIBUTING.md +72 -0
- package/README.md +36 -22
- package/SECURITY.md +16 -0
- package/dist/index.js +856 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +263 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/leaflet.public.js +1273 -0
- package/dist/leaflet.public.js.map +1 -0
- package/dist/leaflet.public.umd.js +276 -0
- package/dist/leaflet.public.umd.js.map +1 -0
- package/dist/maplibregl.js +1297 -0
- package/dist/maplibregl.js.map +1 -0
- package/dist/maplibregl.umd.js +276 -0
- package/dist/maplibregl.umd.js.map +1 -0
- package/dist/maptilersdk.js +1305 -0
- package/dist/maptilersdk.js.map +1 -0
- package/dist/maptilersdk.umd.js +276 -0
- package/dist/maptilersdk.umd.js.map +1 -0
- package/dist/src/components/clear-icon.d.ts +10 -0
- package/dist/src/components/fail-icon.d.ts +10 -0
- package/dist/src/components/loading-icon.d.ts +10 -0
- package/dist/src/components/marker.d.ts +10 -0
- package/dist/src/components/reverse-geocoding-icon.d.ts +10 -0
- package/dist/src/components/search-icon.d.ts +10 -0
- package/dist/src/controls/leaflet-control.d.ts +58 -0
- package/dist/src/controls/leaflet-events.d.ts +42 -0
- package/dist/src/controls/leaflet-options.d.ts +84 -0
- package/dist/src/controls/maplibregl-control.d.ts +55 -0
- package/dist/src/controls/maplibregl-events.d.ts +44 -0
- package/dist/src/controls/maplibregl-options.d.ts +104 -0
- package/dist/src/controls/maptilersdk-control.d.ts +6 -0
- package/dist/src/controls/maptilersdk-events.d.ts +2 -0
- package/dist/src/controls/maptilersdk-options.d.ts +10 -0
- package/dist/src/geocoder/geocoder-events.d.ts +46 -0
- package/dist/src/geocoder/geocoder-feature-item.d.ts +22 -0
- package/{svelte/types.d.ts → dist/src/geocoder/geocoder-options.d.ts} +12 -148
- package/dist/src/geocoder/geocoder.d.ts +112 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/leaflet.public.d.ts +7 -0
- package/dist/src/maplibregl.d.ts +7 -0
- package/dist/src/maptilersdk.d.ts +7 -0
- package/dist/src/types.d.ts +45 -0
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/mask.d.ts +2 -0
- package/dist/src/utils/proximity.d.ts +2 -0
- package/package.json +84 -116
- package/MapLibreBasedGeocodingControl.d.ts +0 -3072
- package/geo-coordinates-parser.t.d.ts +0 -8
- package/geoUtils.d.ts +0 -3
- package/leaflet-controller.d.ts +0 -12
- package/leaflet-controller.js +0 -2475
- package/leaflet-controller.js.map +0 -1
- package/leaflet-controller.umd.js +0 -2
- package/leaflet-controller.umd.js.map +0 -1
- package/leaflet.d.ts +0 -131
- package/leaflet.js +0 -5055
- package/leaflet.js.map +0 -1
- package/leaflet.umd.js +0 -14
- package/leaflet.umd.js.map +0 -1
- package/maplibregl-controller.d.ts +0 -19
- package/maplibregl-controller.js +0 -2418
- package/maplibregl-controller.js.map +0 -1
- package/maplibregl-controller.umd.js +0 -2
- package/maplibregl-controller.umd.js.map +0 -1
- package/maplibregl.d.ts +0 -2509
- package/maplibregl.js +0 -5115
- package/maplibregl.js.map +0 -1
- package/maplibregl.umd.js +0 -14
- package/maplibregl.umd.js.map +0 -1
- package/maptilersdk.d.ts +0 -2504
- package/maptilersdk.js +0 -5125
- package/maptilersdk.js.map +0 -1
- package/maptilersdk.umd.js +0 -14
- package/maptilersdk.umd.js.map +0 -1
- package/mask.d.ts +0 -2
- package/openlayers-controller.d.ts +0 -15
- package/openlayers-controller.js +0 -2174
- package/openlayers-controller.js.map +0 -1
- package/openlayers-controller.umd.js +0 -2
- package/openlayers-controller.umd.js.map +0 -1
- package/openlayers.d.ts +0 -109
- package/openlayers.js +0 -5018
- package/openlayers.js.map +0 -1
- package/openlayers.umd.js +0 -14
- package/openlayers.umd.js.map +0 -1
- package/proximity.d.ts +0 -2
- package/react.d.ts +0 -45
- package/react.js +0 -2768
- package/react.js.map +0 -1
- package/react.umd.js +0 -14
- package/react.umd.js.map +0 -1
- package/style.css +0 -1
- package/svelte/ClearIcon.svelte +0 -12
- package/svelte/ClearIcon.svelte.d.ts +0 -25
- package/svelte/FailIcon.svelte +0 -12
- package/svelte/FailIcon.svelte.d.ts +0 -25
- package/svelte/FeatureItem.svelte +0 -246
- package/svelte/FeatureItem.svelte.d.ts +0 -26
- package/svelte/GeocodingControl.svelte +0 -919
- package/svelte/GeocodingControl.svelte.d.ts +0 -105
- package/svelte/LoadingIcon.svelte +0 -40
- package/svelte/LoadingIcon.svelte.d.ts +0 -25
- package/svelte/MapLibreBasedGeocodingControl.d.ts +0 -3072
- package/svelte/MapLibreBasedGeocodingControl.js +0 -210
- package/svelte/MarkerIcon.svelte +0 -71
- package/svelte/MarkerIcon.svelte.d.ts +0 -18
- package/svelte/ReverseGeocodingIcon.svelte +0 -12
- package/svelte/ReverseGeocodingIcon.svelte.d.ts +0 -25
- package/svelte/SearchIcon.svelte +0 -26
- package/svelte/SearchIcon.svelte.d.ts +0 -25
- package/svelte/geo-coordinates-parser.t.d.ts +0 -8
- package/svelte/geo-coordinates-parser.t.js +0 -1
- package/svelte/geoUtils.d.ts +0 -3
- package/svelte/geoUtils.js +0 -18
- package/svelte/info.json +0 -1
- package/svelte/leaflet-controller.d.ts +0 -12
- package/svelte/leaflet-controller.js +0 -274
- package/svelte/leaflet.d.ts +0 -131
- package/svelte/leaflet.js +0 -116
- package/svelte/maplibregl-controller.d.ts +0 -19
- package/svelte/maplibregl-controller.js +0 -279
- package/svelte/maplibregl.d.ts +0 -2509
- package/svelte/maplibregl.js +0 -17
- package/svelte/maptilersdk.d.ts +0 -2504
- package/svelte/maptilersdk.js +0 -32
- package/svelte/mask.d.ts +0 -2
- package/svelte/mask.js +0 -54
- package/svelte/openlayers-controller.d.ts +0 -15
- package/svelte/openlayers-controller.js +0 -283
- package/svelte/openlayers.d.ts +0 -109
- package/svelte/openlayers.js +0 -178
- package/svelte/proximity.d.ts +0 -2
- package/svelte/proximity.js +0 -60
- package/svelte/react.d.ts +0 -45
- package/svelte/react.js +0 -106
- package/svelte/types.js +0 -1
- package/svelte/vanilla.d.ts +0 -61
- package/svelte/vanilla.js +0 -101
- package/svelte/vite-env.d.ts +0 -2
- package/types.d.ts +0 -391
- package/vanilla.d.ts +0 -61
- package/vanilla.js +0 -2772
- package/vanilla.js.map +0 -1
- package/vanilla.umd.js +0 -14
- package/vanilla.umd.js.map +0 -1
- /package/{icons → dist/icons}/10pin.svg +0 -0
- /package/{icons → dist/icons}/9pin.svg +0 -0
- /package/{icons → dist/icons}/advertising_column.svg +0 -0
- /package/{icons → dist/icons}/aerodrome.svg +0 -0
- /package/{icons → dist/icons}/alcohol.svg +0 -0
- /package/{icons → dist/icons}/alpine_hut.svg +0 -0
- /package/{icons → dist/icons}/amusement_arcade.svg +0 -0
- /package/{icons → dist/icons}/amusement_park.svg +0 -0
- /package/{icons → dist/icons}/apartment.svg +0 -0
- /package/{icons → dist/icons}/archaeological_site.svg +0 -0
- /package/{icons → dist/icons}/area.svg +0 -0
- /package/{icons → dist/icons}/art.svg +0 -0
- /package/{icons → dist/icons}/arts_centre.svg +0 -0
- /package/{icons → dist/icons}/artwork.svg +0 -0
- /package/{icons → dist/icons}/audioguide.svg +0 -0
- /package/{icons → dist/icons}/bag.svg +0 -0
- /package/{icons → dist/icons}/beauty.svg +0 -0
- /package/{icons → dist/icons}/bed.svg +0 -0
- /package/{icons → dist/icons}/bell_tower.svg +0 -0
- /package/{icons → dist/icons}/beverages.svg +0 -0
- /package/{icons → dist/icons}/bicycle_repair_station.svg +0 -0
- /package/{icons → dist/icons}/biergarten.svg +0 -0
- /package/{icons → dist/icons}/bird_hide.svg +0 -0
- /package/{icons → dist/icons}/boat_rental.svg +0 -0
- /package/{icons → dist/icons}/bookmaker.svg +0 -0
- /package/{icons → dist/icons}/books.svg +0 -0
- /package/{icons → dist/icons}/bowl.svg +0 -0
- /package/{icons → dist/icons}/bowling_alley.svg +0 -0
- /package/{icons → dist/icons}/bunker.svg +0 -0
- /package/{icons → dist/icons}/bureau_de_change.svg +0 -0
- /package/{icons → dist/icons}/bus_station.svg +0 -0
- /package/{icons → dist/icons}/bust.svg +0 -0
- /package/{icons → dist/icons}/camping.svg +0 -0
- /package/{icons → dist/icons}/car_parts.svg +0 -0
- /package/{icons → dist/icons}/car_wash.svg +0 -0
- /package/{icons → dist/icons}/caravan_park.svg +0 -0
- /package/{icons → dist/icons}/carpet.svg +0 -0
- /package/{icons → dist/icons}/cattle_grid.svg +0 -0
- /package/{icons → dist/icons}/cave_entrance.svg +0 -0
- /package/{icons → dist/icons}/chalet.svg +0 -0
- /package/{icons → dist/icons}/charity.svg +0 -0
- /package/{icons → dist/icons}/chemist.svg +0 -0
- /package/{icons → dist/icons}/chimney.svg +0 -0
- /package/{icons → dist/icons}/church.svg +0 -0
- /package/{icons → dist/icons}/city_gate.svg +0 -0
- /package/{icons → dist/icons}/clinic.svg +0 -0
- /package/{icons → dist/icons}/clothes.svg +0 -0
- /package/{icons → dist/icons}/coffee.svg +0 -0
- /package/{icons → dist/icons}/community_centre.svg +0 -0
- /package/{icons → dist/icons}/computer.svg +0 -0
- /package/{icons → dist/icons}/consulate.svg +0 -0
- /package/{icons → dist/icons}/copyshop.svg +0 -0
- /package/{icons → dist/icons}/cosmetics.svg +0 -0
- /package/{icons → dist/icons}/courthouse.svg +0 -0
- /package/{icons → dist/icons}/crane.svg +0 -0
- /package/{icons → dist/icons}/dairy.svg +0 -0
- /package/{icons → dist/icons}/deli.svg +0 -0
- /package/{icons → dist/icons}/department_store.svg +0 -0
- /package/{icons → dist/icons}/diy.svg +0 -0
- /package/{icons → dist/icons}/electronics.svg +0 -0
- /package/{icons → dist/icons}/embankment.svg +0 -0
- /package/{icons → dist/icons}/embassy.svg +0 -0
- /package/{icons → dist/icons}/excrement_bags.svg +0 -0
- /package/{icons → dist/icons}/fabric.svg +0 -0
- /package/{icons → dist/icons}/farmyard.svg +0 -0
- /package/{icons → dist/icons}/ferry.svg +0 -0
- /package/{icons → dist/icons}/firepit.svg +0 -0
- /package/{icons → dist/icons}/firestation.svg +0 -0
- /package/{icons → dist/icons}/fishing.svg +0 -0
- /package/{icons → dist/icons}/fitness.svg +0 -0
- /package/{icons → dist/icons}/ford.svg +0 -0
- /package/{icons → dist/icons}/fort.svg +0 -0
- /package/{icons → dist/icons}/fortress.svg +0 -0
- /package/{icons → dist/icons}/full-height_turnstile.svg +0 -0
- /package/{icons → dist/icons}/generator_wind.svg +0 -0
- /package/{icons → dist/icons}/golf_pin.svg +0 -0
- /package/{icons → dist/icons}/greengrocer.svg +0 -0
- /package/{icons → dist/icons}/guest_house.svg +0 -0
- /package/{icons → dist/icons}/helipad.svg +0 -0
- /package/{icons → dist/icons}/hifi.svg +0 -0
- /package/{icons → dist/icons}/hostel.svg +0 -0
- /package/{icons → dist/icons}/hotel.svg +0 -0
- /package/{icons → dist/icons}/housenumber.svg +0 -0
- /package/{icons → dist/icons}/houseware.svg +0 -0
- /package/{icons → dist/icons}/hunting_stand.svg +0 -0
- /package/{icons → dist/icons}/interior_decoration.svg +0 -0
- /package/{icons → dist/icons}/internet_cafe.svg +0 -0
- /package/{icons → dist/icons}/kindergarten.svg +0 -0
- /package/{icons → dist/icons}/kissing_gate.svg +0 -0
- /package/{icons → dist/icons}/manor.svg +0 -0
- /package/{icons → dist/icons}/map.svg +0 -0
- /package/{icons → dist/icons}/marker_reverse.svg +0 -0
- /package/{icons → dist/icons}/marker_selected.svg +0 -0
- /package/{icons → dist/icons}/marker_unselected.svg +0 -0
- /package/{icons → dist/icons}/marketplace.svg +0 -0
- /package/{icons → dist/icons}/massage.svg +0 -0
- /package/{icons → dist/icons}/mast.svg +0 -0
- /package/{icons → dist/icons}/mast_communications.svg +0 -0
- /package/{icons → dist/icons}/mast_lighting.svg +0 -0
- /package/{icons → dist/icons}/medical_supply.svg +0 -0
- /package/{icons → dist/icons}/memorial.svg +0 -0
- /package/{icons → dist/icons}/miniature_golf.svg +0 -0
- /package/{icons → dist/icons}/motel.svg +0 -0
- /package/{icons → dist/icons}/mountain_range.svg +0 -0
- /package/{icons → dist/icons}/multifaith.svg +0 -0
- /package/{icons → dist/icons}/musical_instrument.svg +0 -0
- /package/{icons → dist/icons}/newsagent.svg +0 -0
- /package/{icons → dist/icons}/nightclub.svg +0 -0
- /package/{icons → dist/icons}/ocean.svg +0 -0
- /package/{icons → dist/icons}/office.svg +0 -0
- /package/{icons → dist/icons}/outdoor_seating.svg +0 -0
- /package/{icons → dist/icons}/palace.svg +0 -0
- /package/{icons → dist/icons}/parcel_locker.svg +0 -0
- /package/{icons → dist/icons}/parking_space.svg +0 -0
- /package/{icons → dist/icons}/parking_tickets.svg +0 -0
- /package/{icons → dist/icons}/pet.svg +0 -0
- /package/{icons → dist/icons}/photo.svg +0 -0
- /package/{icons → dist/icons}/picnic.svg +0 -0
- /package/{icons → dist/icons}/plaque.svg +0 -0
- /package/{icons → dist/icons}/poi.svg +0 -0
- /package/{icons → dist/icons}/post_box.svg +0 -0
- /package/{icons → dist/icons}/post_office.svg +0 -0
- /package/{icons → dist/icons}/postal_code.svg +0 -0
- /package/{icons → dist/icons}/pub.svg +0 -0
- /package/{icons → dist/icons}/public_bath.svg +0 -0
- /package/{icons → dist/icons}/public_bookcase.svg +0 -0
- /package/{icons → dist/icons}/public_building.svg +0 -0
- /package/{icons → dist/icons}/public_transport_tickets.svg +0 -0
- /package/{icons → dist/icons}/reverse.svg +0 -0
- /package/{icons → dist/icons}/river.svg +0 -0
- /package/{icons → dist/icons}/road.svg +0 -0
- /package/{icons → dist/icons}/saddle.svg +0 -0
- /package/{icons → dist/icons}/sauna.svg +0 -0
- /package/{icons → dist/icons}/sea.svg +0 -0
- /package/{icons → dist/icons}/second_hand.svg +0 -0
- /package/{icons → dist/icons}/shintoist.svg +0 -0
- /package/{icons → dist/icons}/shoe.svg +0 -0
- /package/{icons → dist/icons}/shower.svg +0 -0
- /package/{icons → dist/icons}/shrine.svg +0 -0
- /package/{icons → dist/icons}/sikhist.svg +0 -0
- /package/{icons → dist/icons}/slipway.svg +0 -0
- /package/{icons → dist/icons}/snowmobile.svg +0 -0
- /package/{icons → dist/icons}/social_facility.svg +0 -0
- /package/{icons → dist/icons}/sports.svg +0 -0
- /package/{icons → dist/icons}/sprite.json +0 -0
- /package/{icons → dist/icons}/sprite.png +0 -0
- /package/{icons → dist/icons}/sprite@2x.json +0 -0
- /package/{icons → dist/icons}/sprite@2x.png +0 -0
- /package/{icons → dist/icons}/stationery.svg +0 -0
- /package/{icons → dist/icons}/stile.svg +0 -0
- /package/{icons → dist/icons}/stone.svg +0 -0
- /package/{icons → dist/icons}/storage_tank.svg +0 -0
- /package/{icons → dist/icons}/stream.svg +0 -0
- /package/{icons → dist/icons}/street.svg +0 -0
- /package/{icons → dist/icons}/supermarket.svg +0 -0
- /package/{icons → dist/icons}/tea.svg +0 -0
- /package/{icons → dist/icons}/telescope_dish.svg +0 -0
- /package/{icons → dist/icons}/telescope_dome.svg +0 -0
- /package/{icons → dist/icons}/ticket.svg +0 -0
- /package/{icons → dist/icons}/tobacco.svg +0 -0
- /package/{icons → dist/icons}/tower_cantilever_communication.svg +0 -0
- /package/{icons → dist/icons}/tower_cooling.svg +0 -0
- /package/{icons → dist/icons}/tower_dish.svg +0 -0
- /package/{icons → dist/icons}/tower_dome.svg +0 -0
- /package/{icons → dist/icons}/tower_generic.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice_communication.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice_lighting.svg +0 -0
- /package/{icons → dist/icons}/tower_lighting.svg +0 -0
- /package/{icons → dist/icons}/townhall.svg +0 -0
- /package/{icons → dist/icons}/toys.svg +0 -0
- /package/{icons → dist/icons}/trade.svg +0 -0
- /package/{icons → dist/icons}/traffic_light.svg +0 -0
- /package/{icons → dist/icons}/train_station.svg +0 -0
- /package/{icons → dist/icons}/travel_agency.svg +0 -0
- /package/{icons → dist/icons}/tyres.svg +0 -0
- /package/{icons → dist/icons}/university.svg +0 -0
- /package/{icons → dist/icons}/variety_store.svg +0 -0
- /package/{icons → dist/icons}/vehicle_inspection.svg +0 -0
- /package/{icons → dist/icons}/vending_machine.svg +0 -0
- /package/{icons → dist/icons}/video.svg +0 -0
- /package/{icons → dist/icons}/video_games.svg +0 -0
- /package/{icons → dist/icons}/waste_disposal.svg +0 -0
- /package/{icons → dist/icons}/water_well.svg +0 -0
- /package/{icons → dist/icons}/waterfall.svg +0 -0
- /package/{icons → dist/icons}/wilderness_hut.svg +0 -0
|
@@ -1,919 +0,0 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, onDestroy } from "svelte";
|
|
2
|
-
import { default as ClearIcon } from "./ClearIcon.svelte";
|
|
3
|
-
import { default as FailIcon } from "./FailIcon.svelte";
|
|
4
|
-
import { default as FeatureItem } from "./FeatureItem.svelte";
|
|
5
|
-
import { default as LoadingIcon } from "./LoadingIcon.svelte";
|
|
6
|
-
import MarkerIcon from "./MarkerIcon.svelte";
|
|
7
|
-
import { default as ReverseGeocodingIcon } from "./ReverseGeocodingIcon.svelte";
|
|
8
|
-
import { default as SearchIcon } from "./SearchIcon.svelte";
|
|
9
|
-
import { unwrapBbox, wrapNum } from "./geoUtils";
|
|
10
|
-
import { getProximity } from "./proximity";
|
|
11
|
-
import { convert } from "geo-coordinates-parser";
|
|
12
|
-
export const ZOOM_DEFAULTS = {
|
|
13
|
-
continental_marine: 4,
|
|
14
|
-
country: 4,
|
|
15
|
-
major_landform: 8,
|
|
16
|
-
region: 5,
|
|
17
|
-
subregion: 6,
|
|
18
|
-
county: 7,
|
|
19
|
-
joint_municipality: 8,
|
|
20
|
-
joint_submunicipality: 9,
|
|
21
|
-
municipality: 10,
|
|
22
|
-
municipal_district: 11,
|
|
23
|
-
locality: 12,
|
|
24
|
-
neighbourhood: 13,
|
|
25
|
-
place: 14,
|
|
26
|
-
postal_code: 14,
|
|
27
|
-
road: 16,
|
|
28
|
-
poi: 17,
|
|
29
|
-
address: 18,
|
|
30
|
-
"poi.peak": 15,
|
|
31
|
-
"poi.shop": 18,
|
|
32
|
-
"poi.cafe": 18,
|
|
33
|
-
"poi.restaurant": 18,
|
|
34
|
-
"poi.aerodrome": 13,
|
|
35
|
-
// TODO add many more
|
|
36
|
-
};
|
|
37
|
-
let className = undefined;
|
|
38
|
-
export { className as class };
|
|
39
|
-
export let apiKey;
|
|
40
|
-
export let bbox = undefined;
|
|
41
|
-
export let clearButtonTitle = "clear";
|
|
42
|
-
export let clearOnBlur = false;
|
|
43
|
-
export let clearListOnPick = false;
|
|
44
|
-
export let keepListOpen = false;
|
|
45
|
-
export let collapsed = false;
|
|
46
|
-
export let country = undefined;
|
|
47
|
-
export let debounceSearch = 200;
|
|
48
|
-
export let enableReverse = "never";
|
|
49
|
-
export let errorMessage = "Something went wrong…";
|
|
50
|
-
export let filter = () => true;
|
|
51
|
-
export let flyTo = true;
|
|
52
|
-
export let fuzzyMatch = true;
|
|
53
|
-
export let language = undefined;
|
|
54
|
-
export let limit = undefined;
|
|
55
|
-
const COPY_LIMIT = +41415112612;
|
|
56
|
-
export let reverseGeocodingLimit = COPY_LIMIT;
|
|
57
|
-
export let mapController = undefined;
|
|
58
|
-
export let minLength = 2;
|
|
59
|
-
export let noResultsMessage = "Oops! Looks like you're trying to predict something that's not quite right. We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term. Keep on typing - we'll do our best to get you where you need to go!";
|
|
60
|
-
export let placeholder = "Search";
|
|
61
|
-
export let proximity = [
|
|
62
|
-
{ type: "server-geolocation" },
|
|
63
|
-
];
|
|
64
|
-
export let reverseActive = enableReverse === "always";
|
|
65
|
-
export let reverseButtonTitle = "toggle reverse geocoding";
|
|
66
|
-
export let searchValue = "";
|
|
67
|
-
export let pickedResultStyle = "full-geometry";
|
|
68
|
-
export let showPlaceType = "if-needed";
|
|
69
|
-
export let showResultsWhileTyping = true;
|
|
70
|
-
export let selectFirst = true;
|
|
71
|
-
export let flyToSelected = false;
|
|
72
|
-
export let markerOnSelected = true;
|
|
73
|
-
export let types = undefined;
|
|
74
|
-
const COPY_TYPES = [];
|
|
75
|
-
export let reverseGeocodingTypes = COPY_TYPES;
|
|
76
|
-
export let exhaustiveReverseGeocoding = false;
|
|
77
|
-
export let excludeTypes = false;
|
|
78
|
-
const COPY_EXCLUDE_TYPES = undefined;
|
|
79
|
-
export let reverseGeocodingExcludeTypes = COPY_EXCLUDE_TYPES;
|
|
80
|
-
export let zoom = ZOOM_DEFAULTS;
|
|
81
|
-
export let apiUrl = "https://api.maptiler.com/geocoding";
|
|
82
|
-
export let fetchParameters = {};
|
|
83
|
-
export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
|
|
84
|
-
"2.1.6" +
|
|
85
|
-
"/icons/";
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated use `adjustUrl`
|
|
88
|
-
*/
|
|
89
|
-
export let adjustUrlQuery = () => { };
|
|
90
|
-
/**
|
|
91
|
-
* Adjust geocoding URL before the fetch.
|
|
92
|
-
*/
|
|
93
|
-
export let adjustUrl = () => { };
|
|
94
|
-
/**
|
|
95
|
-
* Focus the search input box.
|
|
96
|
-
*
|
|
97
|
-
* @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
|
|
98
|
-
*/
|
|
99
|
-
export function focus(options) {
|
|
100
|
-
input.focus(options);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Blur the search input box.
|
|
104
|
-
*/
|
|
105
|
-
export function blur() {
|
|
106
|
-
input.blur();
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Set the content of search input box.
|
|
110
|
-
*
|
|
111
|
-
* @param value text to set
|
|
112
|
-
* @param submit perform the search
|
|
113
|
-
*/
|
|
114
|
-
export function setQuery(value, submit = true, reverse = false) {
|
|
115
|
-
searchValue = value;
|
|
116
|
-
if (submit) {
|
|
117
|
-
selectedItemIndex = -1;
|
|
118
|
-
handleSubmit();
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
handleInput(undefined, !reverse, reverse);
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
input.focus();
|
|
124
|
-
input.select();
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Clear search result list.
|
|
130
|
-
*/
|
|
131
|
-
export function clearList() {
|
|
132
|
-
listFeatures = undefined;
|
|
133
|
-
picked = undefined;
|
|
134
|
-
selectedItemIndex = -1;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Clear geocoding search results from the map.
|
|
138
|
-
*/
|
|
139
|
-
export function clearMap() {
|
|
140
|
-
markedFeatures = [];
|
|
141
|
-
picked = undefined;
|
|
142
|
-
}
|
|
143
|
-
let listFeatures;
|
|
144
|
-
let markedFeatures;
|
|
145
|
-
let picked;
|
|
146
|
-
let lastSearchUrl = "";
|
|
147
|
-
let input;
|
|
148
|
-
let selectedItemIndex = -1;
|
|
149
|
-
let error;
|
|
150
|
-
let cachedFeatures = [];
|
|
151
|
-
let abortController;
|
|
152
|
-
let searchTimeoutRef;
|
|
153
|
-
let focusedDelayed;
|
|
154
|
-
let prevIdToFly;
|
|
155
|
-
let focused = false;
|
|
156
|
-
const missingIconsCache = new Set();
|
|
157
|
-
const dispatch = createEventDispatcher();
|
|
158
|
-
$: reverseActive = enableReverse === "always";
|
|
159
|
-
$: if (pickedResultStyle !== "marker-only" &&
|
|
160
|
-
picked &&
|
|
161
|
-
!picked.address &&
|
|
162
|
-
picked.geometry.type === "Point" &&
|
|
163
|
-
picked.place_type[0] !== "reverse") {
|
|
164
|
-
search(picked.id, { byId: true }).catch((err) => (error = err));
|
|
165
|
-
}
|
|
166
|
-
$: {
|
|
167
|
-
if (mapController && picked && picked.id !== prevIdToFly && flyTo) {
|
|
168
|
-
goToPicked();
|
|
169
|
-
if (clearListOnPick) {
|
|
170
|
-
listFeatures = undefined;
|
|
171
|
-
}
|
|
172
|
-
markedFeatures = undefined;
|
|
173
|
-
selectedItemIndex = -1;
|
|
174
|
-
}
|
|
175
|
-
prevIdToFly = picked?.id;
|
|
176
|
-
}
|
|
177
|
-
$: if (mapController && selected && flyTo && flyToSelected) {
|
|
178
|
-
mapController.flyTo(selected.center, computeZoom(selected));
|
|
179
|
-
}
|
|
180
|
-
$: showPolygonMarker =
|
|
181
|
-
pickedResultStyle === "full-geometry-including-polygon-center-marker";
|
|
182
|
-
// if markerOnSelected was dynamically changed to false
|
|
183
|
-
$: if (!markerOnSelected) {
|
|
184
|
-
mapController?.setFeatures(undefined, undefined, showPolygonMarker);
|
|
185
|
-
}
|
|
186
|
-
$: if (mapController && markerOnSelected && !markedFeatures) {
|
|
187
|
-
mapController.setFeatures(selected ? [selected] : undefined, picked, showPolygonMarker);
|
|
188
|
-
mapController.setSelectedMarker(selected ? 0 : -1);
|
|
189
|
-
}
|
|
190
|
-
$: if (markedFeatures !== listFeatures) {
|
|
191
|
-
markedFeatures = undefined;
|
|
192
|
-
}
|
|
193
|
-
$: if (mapController) {
|
|
194
|
-
mapController.setFeatures(markedFeatures, picked, showPolygonMarker);
|
|
195
|
-
}
|
|
196
|
-
$: if (searchValue.length < minLength) {
|
|
197
|
-
listFeatures = undefined;
|
|
198
|
-
error = undefined;
|
|
199
|
-
markedFeatures = listFeatures;
|
|
200
|
-
}
|
|
201
|
-
// highlight selected marker
|
|
202
|
-
$: if (markedFeatures && mapController) {
|
|
203
|
-
mapController.setSelectedMarker(selectedItemIndex);
|
|
204
|
-
}
|
|
205
|
-
// close dropdown in the next cycle so that the selected item event has the chance to fire
|
|
206
|
-
$: setTimeout(() => {
|
|
207
|
-
focusedDelayed = focused;
|
|
208
|
-
if (clearOnBlur && !focusedDelayed) {
|
|
209
|
-
searchValue = "";
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
$: if (selectFirst &&
|
|
213
|
-
listFeatures?.length &&
|
|
214
|
-
selectedItemIndex == -1 &&
|
|
215
|
-
!picked) {
|
|
216
|
-
selectedItemIndex = 0;
|
|
217
|
-
}
|
|
218
|
-
$: selected = listFeatures?.[selectedItemIndex];
|
|
219
|
-
$: if (mapController) {
|
|
220
|
-
const coords = isQueryReverse(searchValue);
|
|
221
|
-
mapController.setReverseMarker(coords ? [coords.decimalLongitude, coords.decimalLatitude] : undefined);
|
|
222
|
-
}
|
|
223
|
-
$: dispatch("select", { feature: selected });
|
|
224
|
-
$: dispatch("pick", { feature: picked });
|
|
225
|
-
$: optionsVisible =
|
|
226
|
-
!!listFeatures?.length && (focusedDelayed || keepListOpen);
|
|
227
|
-
$: dispatch("optionsvisibilitychange", { optionsVisible });
|
|
228
|
-
$: dispatch("featureslisted", { features: listFeatures });
|
|
229
|
-
$: dispatch("featuresmarked", { features: markedFeatures });
|
|
230
|
-
$: dispatch("reversetoggle", { reverse: reverseActive });
|
|
231
|
-
$: dispatch("querychange", { query: searchValue });
|
|
232
|
-
$: if (mapController) {
|
|
233
|
-
mapController.indicateReverse(reverseActive);
|
|
234
|
-
}
|
|
235
|
-
$: if (mapController) {
|
|
236
|
-
mapController.setEventHandler((e) => {
|
|
237
|
-
switch (e.type) {
|
|
238
|
-
case "mapClick":
|
|
239
|
-
if (reverseActive) {
|
|
240
|
-
handleReverse(e.coordinates);
|
|
241
|
-
}
|
|
242
|
-
break;
|
|
243
|
-
case "markerClick":
|
|
244
|
-
{
|
|
245
|
-
const feature = listFeatures?.find((feature) => feature.id === e.id);
|
|
246
|
-
if (feature) {
|
|
247
|
-
pick(feature);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
break;
|
|
251
|
-
case "markerMouseEnter":
|
|
252
|
-
if (markedFeatures) {
|
|
253
|
-
selectedItemIndex = !focusedDelayed
|
|
254
|
-
? -1
|
|
255
|
-
: (listFeatures?.findIndex((feature) => feature.id === e.id) ??
|
|
256
|
-
-1);
|
|
257
|
-
}
|
|
258
|
-
break;
|
|
259
|
-
case "markerMouseLeave":
|
|
260
|
-
if (markedFeatures) {
|
|
261
|
-
selectedItemIndex = -1;
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
onDestroy(() => {
|
|
268
|
-
if (mapController) {
|
|
269
|
-
mapController.setEventHandler(undefined);
|
|
270
|
-
mapController.indicateReverse(false);
|
|
271
|
-
mapController.setSelectedMarker(-1);
|
|
272
|
-
mapController.setFeatures(undefined, undefined, false);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
function handleSubmit(event) {
|
|
276
|
-
focused = false;
|
|
277
|
-
if (searchTimeoutRef) {
|
|
278
|
-
clearTimeout(searchTimeoutRef);
|
|
279
|
-
searchTimeoutRef = undefined;
|
|
280
|
-
}
|
|
281
|
-
if (selectedItemIndex > -1 && listFeatures) {
|
|
282
|
-
picked = listFeatures[selectedItemIndex];
|
|
283
|
-
searchValue =
|
|
284
|
-
picked.place_type[0] === "reverse"
|
|
285
|
-
? picked.place_name
|
|
286
|
-
: picked.place_name.replace(/,.*/, "");
|
|
287
|
-
error = undefined;
|
|
288
|
-
markedFeatures = undefined;
|
|
289
|
-
selectedItemIndex = -1;
|
|
290
|
-
}
|
|
291
|
-
else if (searchValue) {
|
|
292
|
-
const zoomTo = event || !isQueryReverse(searchValue);
|
|
293
|
-
search(searchValue, { exact: true })
|
|
294
|
-
.then(() => {
|
|
295
|
-
markedFeatures = listFeatures;
|
|
296
|
-
picked = undefined;
|
|
297
|
-
if (zoomTo) {
|
|
298
|
-
zoomToResults();
|
|
299
|
-
}
|
|
300
|
-
})
|
|
301
|
-
.catch((err) => (error = err));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
function isQueryReverse(searchValue) {
|
|
305
|
-
try {
|
|
306
|
-
return convert(searchValue, 6);
|
|
307
|
-
}
|
|
308
|
-
catch {
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
async function search(searchValue, { byId = false, exact = false, } = {}) {
|
|
313
|
-
error = undefined;
|
|
314
|
-
abortController?.abort();
|
|
315
|
-
const ac = new AbortController();
|
|
316
|
-
abortController = ac;
|
|
317
|
-
try {
|
|
318
|
-
const isReverse = isQueryReverse(searchValue);
|
|
319
|
-
const urlObj = new URL(apiUrl +
|
|
320
|
-
"/" +
|
|
321
|
-
encodeURIComponent(isReverse
|
|
322
|
-
? isReverse.decimalLongitude + "," + isReverse.decimalLatitude
|
|
323
|
-
: searchValue) +
|
|
324
|
-
".json");
|
|
325
|
-
const sp = urlObj.searchParams;
|
|
326
|
-
if (language !== undefined) {
|
|
327
|
-
sp.set("language", Array.isArray(language) ? language.join(",") : (language ?? ""));
|
|
328
|
-
}
|
|
329
|
-
const [zoom] = mapController?.getCenterAndZoom() ?? [];
|
|
330
|
-
let effTypes = (!isReverse || reverseGeocodingTypes === COPY_TYPES
|
|
331
|
-
? types
|
|
332
|
-
: reverseGeocodingTypes)
|
|
333
|
-
?.map((typeRule) => typeof typeRule === "string"
|
|
334
|
-
? typeRule
|
|
335
|
-
: zoom === undefined ||
|
|
336
|
-
((typeRule[0] ?? 0) <= zoom && zoom < (typeRule[1] ?? Infinity))
|
|
337
|
-
? typeRule[2]
|
|
338
|
-
: undefined)
|
|
339
|
-
.filter((type) => type !== undefined);
|
|
340
|
-
if (effTypes) {
|
|
341
|
-
effTypes = [...new Set(effTypes)];
|
|
342
|
-
sp.set("types", effTypes.join(","));
|
|
343
|
-
}
|
|
344
|
-
const effExcludeTypes = !isReverse || reverseGeocodingExcludeTypes === COPY_EXCLUDE_TYPES
|
|
345
|
-
? excludeTypes
|
|
346
|
-
: reverseGeocodingExcludeTypes;
|
|
347
|
-
if (effExcludeTypes) {
|
|
348
|
-
sp.set("excludeTypes", String(effExcludeTypes));
|
|
349
|
-
}
|
|
350
|
-
if (bbox) {
|
|
351
|
-
sp.set("bbox", bbox.map((c) => c.toFixed(6)).join(","));
|
|
352
|
-
}
|
|
353
|
-
if (country) {
|
|
354
|
-
sp.set("country", Array.isArray(country) ? country.join(",") : country);
|
|
355
|
-
}
|
|
356
|
-
if (!byId && !isReverse) {
|
|
357
|
-
const coords = await getProximity(mapController, proximity, ac);
|
|
358
|
-
if (coords) {
|
|
359
|
-
sp.set("proximity", coords);
|
|
360
|
-
}
|
|
361
|
-
if (exact || !showResultsWhileTyping) {
|
|
362
|
-
sp.set("autocomplete", "false");
|
|
363
|
-
}
|
|
364
|
-
sp.set("fuzzyMatch", String(fuzzyMatch));
|
|
365
|
-
}
|
|
366
|
-
const effReverseGeocodingLimit = reverseGeocodingLimit === COPY_LIMIT ? limit : reverseGeocodingLimit;
|
|
367
|
-
if (effReverseGeocodingLimit !== undefined &&
|
|
368
|
-
effReverseGeocodingLimit > 1 &&
|
|
369
|
-
effTypes?.length !== 1) {
|
|
370
|
-
console.warn("For reverse geocoding when limit > 1 then types must contain single value.");
|
|
371
|
-
}
|
|
372
|
-
if (isReverse) {
|
|
373
|
-
if (effReverseGeocodingLimit === 1 ||
|
|
374
|
-
(effReverseGeocodingLimit !== undefined &&
|
|
375
|
-
(exhaustiveReverseGeocoding || effTypes?.length === 1))) {
|
|
376
|
-
sp.set("limit", String(effReverseGeocodingLimit));
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
else if (limit !== undefined) {
|
|
380
|
-
sp.set("limit", String(limit));
|
|
381
|
-
}
|
|
382
|
-
if (apiKey) {
|
|
383
|
-
sp.set("key", apiKey);
|
|
384
|
-
}
|
|
385
|
-
adjustUrlQuery(sp);
|
|
386
|
-
adjustUrl(urlObj);
|
|
387
|
-
const noTypes = urlObj.searchParams.get("types") === "" &&
|
|
388
|
-
urlObj.searchParams.get("excludeTypes") !== "true";
|
|
389
|
-
const url = urlObj.toString();
|
|
390
|
-
if (url === lastSearchUrl) {
|
|
391
|
-
if (byId) {
|
|
392
|
-
if (clearListOnPick) {
|
|
393
|
-
listFeatures = undefined;
|
|
394
|
-
}
|
|
395
|
-
picked = cachedFeatures[0];
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
listFeatures = cachedFeatures;
|
|
399
|
-
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
400
|
-
selectedItemIndex = -1;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
lastSearchUrl = url;
|
|
406
|
-
let featureCollection;
|
|
407
|
-
if (noTypes) {
|
|
408
|
-
featureCollection = { type: "FeatureCollection", features: [] };
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
const res = await fetch(url, {
|
|
412
|
-
signal: ac.signal,
|
|
413
|
-
...fetchParameters,
|
|
414
|
-
});
|
|
415
|
-
if (!res.ok) {
|
|
416
|
-
throw new Error(await res.text());
|
|
417
|
-
}
|
|
418
|
-
featureCollection = await res.json();
|
|
419
|
-
}
|
|
420
|
-
dispatch("response", { url, featureCollection });
|
|
421
|
-
if (byId) {
|
|
422
|
-
if (clearListOnPick) {
|
|
423
|
-
listFeatures = undefined;
|
|
424
|
-
}
|
|
425
|
-
picked = featureCollection.features[0];
|
|
426
|
-
cachedFeatures = [picked];
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
listFeatures = featureCollection.features.filter(filter);
|
|
430
|
-
if (isReverse) {
|
|
431
|
-
listFeatures.unshift({
|
|
432
|
-
type: "Feature",
|
|
433
|
-
properties: {},
|
|
434
|
-
id: "reverse_" +
|
|
435
|
-
isReverse.decimalLongitude +
|
|
436
|
-
"_" +
|
|
437
|
-
isReverse.decimalLatitude,
|
|
438
|
-
text: isReverse.decimalLatitude + ", " + isReverse.decimalLongitude,
|
|
439
|
-
place_name: isReverse.decimalLatitude + ", " + isReverse.decimalLongitude,
|
|
440
|
-
place_type: ["reverse"],
|
|
441
|
-
center: [isReverse.decimalLongitude, isReverse.decimalLatitude],
|
|
442
|
-
bbox: [
|
|
443
|
-
isReverse.decimalLongitude,
|
|
444
|
-
isReverse.decimalLatitude,
|
|
445
|
-
isReverse.decimalLongitude,
|
|
446
|
-
isReverse.decimalLatitude,
|
|
447
|
-
],
|
|
448
|
-
geometry: {
|
|
449
|
-
type: "Point",
|
|
450
|
-
coordinates: [
|
|
451
|
-
isReverse.decimalLongitude,
|
|
452
|
-
isReverse.decimalLatitude,
|
|
453
|
-
],
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
cachedFeatures = listFeatures;
|
|
458
|
-
if (listFeatures[selectedItemIndex]?.id !== selected?.id) {
|
|
459
|
-
selectedItemIndex = -1;
|
|
460
|
-
}
|
|
461
|
-
if (isReverse) {
|
|
462
|
-
input.focus();
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
catch (e) {
|
|
467
|
-
if (e &&
|
|
468
|
-
typeof e === "object" &&
|
|
469
|
-
"name" in e &&
|
|
470
|
-
e.name === "AbortError") {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
throw e;
|
|
474
|
-
}
|
|
475
|
-
finally {
|
|
476
|
-
if (ac === abortController) {
|
|
477
|
-
abortController = undefined;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
function zoomToResults() {
|
|
482
|
-
if (!markedFeatures?.length || !flyTo) {
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
const bbox = [180, 90, -180, -90];
|
|
486
|
-
const fuzzyOnly = !markedFeatures.some((feature) => !feature.matching_text);
|
|
487
|
-
let allZoom;
|
|
488
|
-
for (const feature of markedFeatures) {
|
|
489
|
-
const featZoom = computeZoom(feature);
|
|
490
|
-
allZoom =
|
|
491
|
-
allZoom === undefined
|
|
492
|
-
? featZoom
|
|
493
|
-
: featZoom === undefined
|
|
494
|
-
? allZoom
|
|
495
|
-
: Math.max(allZoom, featZoom);
|
|
496
|
-
if (fuzzyOnly || !feature.matching_text) {
|
|
497
|
-
for (const i of [0, 1, 2, 3]) {
|
|
498
|
-
bbox[i] = Math[i < 2 ? "min" : "max"](bbox[i], feature.bbox?.[i] ?? feature.center[i % 2]);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
if (mapController && markedFeatures.length > 0) {
|
|
503
|
-
if (picked && bbox[0] === bbox[2] && bbox[1] === bbox[3]) {
|
|
504
|
-
mapController.flyTo(picked.center, computeZoom(picked));
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
mapController.fitBounds(unwrapBbox(bbox), 50, allZoom);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function goToPicked() {
|
|
512
|
-
if (!picked || !mapController) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
if (!picked.bbox ||
|
|
516
|
-
(picked.bbox[0] === picked.bbox[2] && picked.bbox[1] === picked.bbox[3])) {
|
|
517
|
-
mapController.flyTo(picked.center, computeZoom(picked));
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
mapController.fitBounds(unwrapBbox(picked.bbox), 50, computeZoom(picked));
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function computeZoom(feature) {
|
|
524
|
-
if (!feature.bbox ||
|
|
525
|
-
(feature.bbox[0] !== feature.bbox[2] &&
|
|
526
|
-
feature.bbox[1] !== feature.bbox[3])) {
|
|
527
|
-
return undefined;
|
|
528
|
-
}
|
|
529
|
-
const index = feature.id.replace(/\..*/, "");
|
|
530
|
-
return ((Array.isArray(feature.properties?.categories)
|
|
531
|
-
? feature.properties.categories.reduce((a, category) => {
|
|
532
|
-
const b = zoom[index + "." + category];
|
|
533
|
-
return a === undefined ? b : b === undefined ? a : Math.max(a, b);
|
|
534
|
-
}, undefined)
|
|
535
|
-
: undefined) ?? zoom[index]);
|
|
536
|
-
}
|
|
537
|
-
function handleReverse(coordinates) {
|
|
538
|
-
reverseActive = enableReverse === "always";
|
|
539
|
-
listFeatures = undefined;
|
|
540
|
-
picked = undefined;
|
|
541
|
-
selectedItemIndex = -1;
|
|
542
|
-
setQuery(coordinates[1].toFixed(6) +
|
|
543
|
-
", " +
|
|
544
|
-
wrapNum(coordinates[0], [-180, 180], true).toFixed(6), false, true);
|
|
545
|
-
}
|
|
546
|
-
function handleKeyDown(e) {
|
|
547
|
-
if (!listFeatures) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
let dir = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
|
|
551
|
-
if (!dir) {
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
input.focus();
|
|
555
|
-
focused = true;
|
|
556
|
-
e.preventDefault();
|
|
557
|
-
if (picked && selectedItemIndex === -1) {
|
|
558
|
-
selectedItemIndex = listFeatures.findIndex((listFeature) => listFeature.id === picked?.id);
|
|
559
|
-
}
|
|
560
|
-
if (selectedItemIndex === (picked || selectFirst ? 0 : -1) && dir === -1) {
|
|
561
|
-
selectedItemIndex = listFeatures.length;
|
|
562
|
-
}
|
|
563
|
-
selectedItemIndex += dir;
|
|
564
|
-
if (selectedItemIndex >= listFeatures.length) {
|
|
565
|
-
selectedItemIndex = -1;
|
|
566
|
-
}
|
|
567
|
-
if (selectedItemIndex < 0 && (picked || selectFirst)) {
|
|
568
|
-
selectedItemIndex = 0;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
function handleInput(_, debounce = true, reverse = false) {
|
|
572
|
-
error = undefined;
|
|
573
|
-
picked = undefined;
|
|
574
|
-
focused = true;
|
|
575
|
-
if (showResultsWhileTyping || reverse) {
|
|
576
|
-
if (searchTimeoutRef) {
|
|
577
|
-
clearTimeout(searchTimeoutRef);
|
|
578
|
-
}
|
|
579
|
-
if (searchValue.length < minLength) {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
const sv = searchValue;
|
|
583
|
-
searchTimeoutRef = window.setTimeout(() => {
|
|
584
|
-
search(sv).catch((err) => (error = err));
|
|
585
|
-
}, debounce ? debounceSearch : 0);
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
listFeatures = undefined;
|
|
589
|
-
error = undefined;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function pick(feature) {
|
|
593
|
-
if (picked && picked?.id === feature?.id) {
|
|
594
|
-
goToPicked();
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
picked = feature;
|
|
598
|
-
searchValue = feature.place_name;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
function handleMouseEnter(index) {
|
|
602
|
-
selectedItemIndex = index;
|
|
603
|
-
}
|
|
604
|
-
function handleMouseLeave() {
|
|
605
|
-
if (!selectFirst || picked) {
|
|
606
|
-
selectedItemIndex = -1;
|
|
607
|
-
}
|
|
608
|
-
// re-focus on picked
|
|
609
|
-
if (flyToSelected) {
|
|
610
|
-
goToPicked();
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
</script>
|
|
614
|
-
|
|
615
|
-
{#if false}
|
|
616
|
-
<!-- This workaround is just to use marker styles. Bug in svlete/vite? Investigate. -->
|
|
617
|
-
<MarkerIcon displayIn="list" />
|
|
618
|
-
{/if}
|
|
619
|
-
|
|
620
|
-
<form
|
|
621
|
-
on:submit|preventDefault={handleSubmit}
|
|
622
|
-
class:can-collapse={collapsed && searchValue === ""}
|
|
623
|
-
class={className}
|
|
624
|
-
>
|
|
625
|
-
<div class="input-group">
|
|
626
|
-
<button class="search-button" type="button" on:click={() => input.focus()}>
|
|
627
|
-
<SearchIcon />
|
|
628
|
-
</button>
|
|
629
|
-
|
|
630
|
-
<input
|
|
631
|
-
bind:this={input}
|
|
632
|
-
bind:value={searchValue}
|
|
633
|
-
on:focus={() => (focused = true)}
|
|
634
|
-
on:blur={() => (focused = false)}
|
|
635
|
-
on:click={() => (focused = true)}
|
|
636
|
-
on:keydown={handleKeyDown}
|
|
637
|
-
on:input={handleInput}
|
|
638
|
-
on:change={() => (picked = undefined)}
|
|
639
|
-
{placeholder}
|
|
640
|
-
aria-label={placeholder}
|
|
641
|
-
/>
|
|
642
|
-
|
|
643
|
-
<div class="clear-button-container" class:displayable={searchValue !== ""}>
|
|
644
|
-
<button
|
|
645
|
-
type="button"
|
|
646
|
-
on:click={() => {
|
|
647
|
-
searchValue = "";
|
|
648
|
-
picked = undefined;
|
|
649
|
-
input.focus();
|
|
650
|
-
}}
|
|
651
|
-
title={clearButtonTitle}
|
|
652
|
-
>
|
|
653
|
-
<ClearIcon />
|
|
654
|
-
</button>
|
|
655
|
-
|
|
656
|
-
{#if abortController}
|
|
657
|
-
<LoadingIcon />
|
|
658
|
-
{/if}
|
|
659
|
-
</div>
|
|
660
|
-
|
|
661
|
-
{#if enableReverse === "button"}
|
|
662
|
-
<button
|
|
663
|
-
type="button"
|
|
664
|
-
class:active={reverseActive}
|
|
665
|
-
title={reverseButtonTitle}
|
|
666
|
-
on:click={() => (reverseActive = !reverseActive)}
|
|
667
|
-
>
|
|
668
|
-
<ReverseGeocodingIcon />
|
|
669
|
-
</button>
|
|
670
|
-
{/if}
|
|
671
|
-
|
|
672
|
-
<slot />
|
|
673
|
-
</div>
|
|
674
|
-
|
|
675
|
-
{#if error}
|
|
676
|
-
<div class="error">
|
|
677
|
-
<FailIcon />
|
|
678
|
-
|
|
679
|
-
<div>{errorMessage}</div>
|
|
680
|
-
|
|
681
|
-
<button on:click={() => (error = undefined)}>
|
|
682
|
-
<ClearIcon />
|
|
683
|
-
</button>
|
|
684
|
-
</div>
|
|
685
|
-
{:else if !focusedDelayed && !keepListOpen}
|
|
686
|
-
{""}
|
|
687
|
-
{:else if listFeatures?.length === 0}
|
|
688
|
-
<div class="no-results">
|
|
689
|
-
<FailIcon />
|
|
690
|
-
|
|
691
|
-
<div>{noResultsMessage}</div>
|
|
692
|
-
</div>
|
|
693
|
-
{:else if listFeatures?.length && (focusedDelayed || keepListOpen)}
|
|
694
|
-
<ul
|
|
695
|
-
class="options"
|
|
696
|
-
on:mouseleave={handleMouseLeave}
|
|
697
|
-
on:blur={() => undefined}
|
|
698
|
-
on:keydown={handleKeyDown}
|
|
699
|
-
role="listbox"
|
|
700
|
-
>
|
|
701
|
-
{#each listFeatures as feature, i (feature.id + (feature.address ? "," + feature.address : ""))}
|
|
702
|
-
<FeatureItem
|
|
703
|
-
{feature}
|
|
704
|
-
{showPlaceType}
|
|
705
|
-
style={selectedItemIndex === i
|
|
706
|
-
? "selected"
|
|
707
|
-
: picked?.id === feature.id
|
|
708
|
-
? "picked"
|
|
709
|
-
: "default"}
|
|
710
|
-
on:mouseenter={() => handleMouseEnter(i)}
|
|
711
|
-
on:select={() => pick(feature)}
|
|
712
|
-
{missingIconsCache}
|
|
713
|
-
{iconsBaseUrl}
|
|
714
|
-
/>
|
|
715
|
-
{/each}
|
|
716
|
-
</ul>
|
|
717
|
-
{/if}
|
|
718
|
-
</form>
|
|
719
|
-
|
|
720
|
-
<style>form {
|
|
721
|
-
font-family: "Open Sans", "Ubuntu", "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
722
|
-
position: relative;
|
|
723
|
-
background-color: #fff;
|
|
724
|
-
z-index: 10;
|
|
725
|
-
border-radius: 4px;
|
|
726
|
-
margin: 0;
|
|
727
|
-
transition: max-width 0.25s;
|
|
728
|
-
box-shadow: 0px 2px 5px rgba(51, 51, 89, 0.15);
|
|
729
|
-
--color-text: #444952;
|
|
730
|
-
--color-icon-button: #444952;
|
|
731
|
-
}
|
|
732
|
-
form, form *, form *:after, form *:before {
|
|
733
|
-
box-sizing: border-box;
|
|
734
|
-
}
|
|
735
|
-
form.can-collapse {
|
|
736
|
-
max-width: 29px;
|
|
737
|
-
}
|
|
738
|
-
form.can-collapse input::placeholder {
|
|
739
|
-
transition: opacity 0.25s;
|
|
740
|
-
opacity: 0;
|
|
741
|
-
}
|
|
742
|
-
form, form:focus-within, form:hover {
|
|
743
|
-
width: 270px;
|
|
744
|
-
max-width: 270px;
|
|
745
|
-
}
|
|
746
|
-
form input::placeholder, form:focus-within input::placeholder, form:hover input::placeholder {
|
|
747
|
-
opacity: 1;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
input {
|
|
751
|
-
font: inherit;
|
|
752
|
-
font-size: 14px;
|
|
753
|
-
flex-grow: 1;
|
|
754
|
-
min-height: 29px;
|
|
755
|
-
background-color: transparent;
|
|
756
|
-
color: #444952;
|
|
757
|
-
white-space: nowrap;
|
|
758
|
-
overflow: hidden;
|
|
759
|
-
border: 0;
|
|
760
|
-
margin: 0;
|
|
761
|
-
padding: 0;
|
|
762
|
-
}
|
|
763
|
-
input:focus {
|
|
764
|
-
color: #444952;
|
|
765
|
-
outline: 0;
|
|
766
|
-
outline: none;
|
|
767
|
-
box-shadow: none;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
ul,
|
|
771
|
-
div.error,
|
|
772
|
-
div.no-results {
|
|
773
|
-
background-color: #fff;
|
|
774
|
-
border-radius: 4px;
|
|
775
|
-
left: 0;
|
|
776
|
-
list-style: none;
|
|
777
|
-
margin: 0;
|
|
778
|
-
padding: 0;
|
|
779
|
-
position: absolute;
|
|
780
|
-
width: 100%;
|
|
781
|
-
top: calc(100% + 6px);
|
|
782
|
-
overflow: hidden;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
ul {
|
|
786
|
-
font-size: 14px;
|
|
787
|
-
line-height: 16px;
|
|
788
|
-
box-shadow: 0px 5px 10px rgba(51, 51, 89, 0.15);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
div.error,
|
|
792
|
-
div.no-results {
|
|
793
|
-
font: inherit;
|
|
794
|
-
line-height: 18px;
|
|
795
|
-
font-size: 12px;
|
|
796
|
-
display: flex;
|
|
797
|
-
gap: 16px;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
div.error {
|
|
801
|
-
padding: 16px;
|
|
802
|
-
font-weight: 600;
|
|
803
|
-
color: #e25041;
|
|
804
|
-
background-color: #fbeae8;
|
|
805
|
-
}
|
|
806
|
-
div.error div {
|
|
807
|
-
flex-grow: 1;
|
|
808
|
-
}
|
|
809
|
-
div.error :global(svg) {
|
|
810
|
-
flex-shrink: 0;
|
|
811
|
-
width: 20px;
|
|
812
|
-
height: 20px;
|
|
813
|
-
}
|
|
814
|
-
div.error button {
|
|
815
|
-
flex-shrink: 0;
|
|
816
|
-
}
|
|
817
|
-
div.error button > :global(svg) {
|
|
818
|
-
width: 13px;
|
|
819
|
-
fill: #e25041;
|
|
820
|
-
}
|
|
821
|
-
div.error button:hover :global(svg), div.error button:active :global(svg) {
|
|
822
|
-
fill: #444952;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
div.no-results {
|
|
826
|
-
padding: 14px 24px 14px 16px;
|
|
827
|
-
font-weight: 400;
|
|
828
|
-
color: #6b7c93;
|
|
829
|
-
box-shadow: 0px 5px 10px rgba(51, 51, 89, 0.15);
|
|
830
|
-
}
|
|
831
|
-
div.no-results :global(svg) {
|
|
832
|
-
margin-top: 4px;
|
|
833
|
-
flex-shrink: 0;
|
|
834
|
-
width: 20px;
|
|
835
|
-
height: 20px;
|
|
836
|
-
width: 30px;
|
|
837
|
-
height: 30px;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
:global(.leaflet-bottom) ul.options,
|
|
841
|
-
:global(.maplibregl-ctrl-bottom-left) ul.options,
|
|
842
|
-
:global(.maplibregl-ctrl-bottom-right) ul.options {
|
|
843
|
-
top: auto;
|
|
844
|
-
bottom: calc(100% + 6px);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
button {
|
|
848
|
-
padding: 0;
|
|
849
|
-
margin: 0;
|
|
850
|
-
border: 0;
|
|
851
|
-
background-color: transparent;
|
|
852
|
-
height: auto;
|
|
853
|
-
width: auto;
|
|
854
|
-
}
|
|
855
|
-
button:hover {
|
|
856
|
-
background-color: transparent;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
button:hover :global(svg),
|
|
860
|
-
button:active :global(svg) {
|
|
861
|
-
fill: #2b8bfb;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
.input-group {
|
|
865
|
-
display: flex;
|
|
866
|
-
align-items: stretch;
|
|
867
|
-
gap: 7px;
|
|
868
|
-
padding-inline: 8px;
|
|
869
|
-
border-radius: 4px;
|
|
870
|
-
overflow: hidden;
|
|
871
|
-
}
|
|
872
|
-
.input-group:focus-within {
|
|
873
|
-
outline: #2b8bfb solid 2px;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
.search-button {
|
|
877
|
-
flex-shrink: 0;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
:global(.maplibregl-ctrl-geocoder:not(.maptiler-ctrl) .search-button svg) {
|
|
881
|
-
width: 12px !important;
|
|
882
|
-
transform: translate(0.5px, 0);
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
.clear-button-container {
|
|
886
|
-
display: flex;
|
|
887
|
-
display: none;
|
|
888
|
-
position: relative;
|
|
889
|
-
align-items: stretch;
|
|
890
|
-
}
|
|
891
|
-
.clear-button-container.displayable {
|
|
892
|
-
display: flex;
|
|
893
|
-
flex-shrink: 0;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
:global(.maplibregl-ctrl-geocoder) {
|
|
897
|
-
position: relative;
|
|
898
|
-
z-index: 3;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
:global(.maptiler-ctrl):not(:empty) {
|
|
902
|
-
box-shadow: none;
|
|
903
|
-
}
|
|
904
|
-
:global(.maptiler-ctrl) .input-group {
|
|
905
|
-
padding-inline: 8px;
|
|
906
|
-
border: white solid 2px;
|
|
907
|
-
}
|
|
908
|
-
:global(.maptiler-ctrl) .input-group:focus-within {
|
|
909
|
-
border: #2b8bfb solid 2px;
|
|
910
|
-
outline: 0;
|
|
911
|
-
outline: none;
|
|
912
|
-
}
|
|
913
|
-
:global(.maptiler-ctrl) form.can-collapse {
|
|
914
|
-
max-width: 33px;
|
|
915
|
-
}
|
|
916
|
-
:global(.maptiler-ctrl) form, :global(.maptiler-ctrl) form:focus-within, :global(.maptiler-ctrl) form:hover {
|
|
917
|
-
width: 270px;
|
|
918
|
-
max-width: 270px;
|
|
919
|
-
}</style>
|