@maptiler/geocoding-control 0.0.91-git.4d23c0 → 0.0.91-git.535bd0

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.
@@ -8,7 +8,7 @@ $: imageUrl = category
8
8
  ? `/icons/${category.replace(/ /g, "_")}.svg`
9
9
  : undefined;
10
10
  $: placeType = feature.id.startsWith("poi.")
11
- ? feature.properties?.categories?.join(" ,")
11
+ ? feature.properties?.categories?.join(", ")
12
12
  : feature.properties?.place_type_name?.[0] ?? feature.place_type[0];
13
13
  function handleImgError(e) {
14
14
  if (index > -1) {
@@ -37,6 +37,7 @@ export let trackProximity = true;
37
37
  export let types = undefined;
38
38
  export let zoom = 16;
39
39
  export let maxZoom = 18;
40
+ export let apiUrl = import.meta.env.VITE_API_URL;
40
41
  export let fetchParameters = {};
41
42
  export function focus() {
42
43
  input.focus();
@@ -70,6 +71,7 @@ let cachedFeatures = [];
70
71
  let abortController;
71
72
  let searchTimeoutRef;
72
73
  let focusedDelayed;
74
+ let prevIdToFly;
73
75
  const dispatch = createEventDispatcher();
74
76
  $: if (!trackProximity) {
75
77
  proximity = undefined;
@@ -80,19 +82,22 @@ $: if (showFullGeometry &&
80
82
  picked.geometry.type === "Point") {
81
83
  search(picked.id, { byId: true }).catch((err) => (error = err));
82
84
  }
83
- $: if (mapController && picked && flyTo) {
84
- if (!picked.bbox ||
85
- (picked.bbox[0] === picked.bbox[2] && picked.bbox[1] === picked.bbox[3])) {
86
- mapController.flyTo(picked.center, picked.id.startsWith("poi.") || picked.id.startsWith("address.")
87
- ? maxZoom
88
- : zoom);
89
- }
90
- else {
91
- mapController.fitBounds(unwrapBbox(picked.bbox), 50, maxZoom);
85
+ $: {
86
+ if (mapController && picked && picked.id !== prevIdToFly && flyTo) {
87
+ if (!picked.bbox ||
88
+ (picked.bbox[0] === picked.bbox[2] && picked.bbox[1] === picked.bbox[3])) {
89
+ mapController.flyTo(picked.center, picked.id.startsWith("poi.") || picked.id.startsWith("address.")
90
+ ? maxZoom
91
+ : zoom);
92
+ }
93
+ else {
94
+ mapController.fitBounds(unwrapBbox(picked.bbox), 50, maxZoom);
95
+ }
96
+ listFeatures = undefined;
97
+ markedFeatures = undefined;
98
+ selectedItemIndex = -1;
92
99
  }
93
- listFeatures = undefined;
94
- markedFeatures = undefined;
95
- selectedItemIndex = -1;
100
+ prevIdToFly = picked?.id;
96
101
  }
97
102
  $: if (markedFeatures !== listFeatures) {
98
103
  markedFeatures = undefined;
@@ -232,11 +237,7 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
232
237
  sp.set("limit", String(limit));
233
238
  }
234
239
  sp.set("key", apiKey);
235
- const url = import.meta.env.VITE_API_URL +
236
- "/" +
237
- encodeURIComponent(searchValue) +
238
- ".json?" +
239
- sp.toString();
240
+ const url = apiUrl + "/" + encodeURIComponent(searchValue) + ".json?" + sp.toString();
240
241
  if (url === lastSearchUrl) {
241
242
  if (byId) {
242
243
  listFeatures = undefined;
@@ -32,6 +32,7 @@ declare const __propDef: {
32
32
  types?: string[] | undefined;
33
33
  zoom?: number | undefined;
34
34
  maxZoom?: number | undefined;
35
+ apiUrl?: string | undefined;
35
36
  fetchParameters?: RequestInit | undefined;
36
37
  focus?: (() => void) | undefined;
37
38
  blur?: (() => void) | undefined;