@maptiler/geocoding-control 0.0.91-git.9f388b → 0.0.91

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.
@@ -1,22 +1,28 @@
1
1
  <script>export let feature;
2
2
  export let selected = false;
3
3
  export let showPlaceType;
4
+ export let missingIconsCache;
4
5
  const categories = feature.properties?.categories;
5
- $: index = (categories?.length ?? 0) - 1;
6
- $: category = categories?.[index];
7
- $: imageUrl = category
8
- ? `/icons/${category.replace(/ /g, "_")}.svg`
9
- : undefined;
6
+ let category;
7
+ let imageUrl;
8
+ $: index = categories?.length ?? 0;
9
+ $: {
10
+ do {
11
+ index--;
12
+ category = categories?.[index];
13
+ imageUrl = category
14
+ ? `/icons/${category.replace(/ /g, "_")}.svg`
15
+ : undefined;
16
+ } while (index > -1 && (!imageUrl || missingIconsCache.has(imageUrl)));
17
+ }
10
18
  $: placeType = feature.id.startsWith("poi.")
11
19
  ? feature.properties?.categories?.join(", ")
12
20
  : feature.properties?.place_type_name?.[0] ?? feature.place_type[0];
13
21
  function handleImgError(e) {
14
- if (index > -1) {
15
- index--;
16
- }
17
- else {
18
- e.style.visibility = "hidden";
22
+ if (imageUrl) {
23
+ missingIconsCache.add(imageUrl);
19
24
  }
25
+ index--;
20
26
  }
21
27
  </script>
22
28
 
@@ -5,6 +5,7 @@ declare const __propDef: {
5
5
  feature: Feature;
6
6
  selected?: boolean | undefined;
7
7
  showPlaceType: false | "always" | "ifNeeded";
8
+ missingIconsCache: Set<string>;
8
9
  };
9
10
  events: {
10
11
  mouseenter: MouseEvent;
@@ -72,6 +72,7 @@ let abortController;
72
72
  let searchTimeoutRef;
73
73
  let focusedDelayed;
74
74
  let prevIdToFly;
75
+ const missingIconsCache = new Set();
75
76
  const dispatch = createEventDispatcher();
76
77
  $: if (!trackProximity) {
77
78
  proximity = undefined;
@@ -460,6 +461,7 @@ function unwrapBbox(bbox0) {
460
461
  selected={selectedItemIndex === i}
461
462
  on:mouseenter={() => (selectedItemIndex = i)}
462
463
  on:focus={() => pick(feature)}
464
+ {missingIconsCache}
463
465
  />
464
466
  {/each}
465
467
  </ul>