diff --git a/lib/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/lib/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index d517db99..44cc200f 100644 --- a/lib/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/lib/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -11,7 +11,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-call */ import FlagIcon from '@heroicons/react/24/outline/FlagIcon' -import MagnifyingGlassIcon from '@heroicons/react/24/outline/MagnifyingGlassIcon' +import MapPinIcon from '@heroicons/react/24/outline/MapPinIcon' import axios from 'axios' import { LatLng, LatLngBounds, marker } from 'leaflet' import { useRef, useState } from 'react' @@ -167,56 +167,85 @@ export const SearchControl = () => { {itemsResults.length > 0 && tagsResults.length > 0 && (
)} - {itemsResults.slice(0, 5).map((item) => ( -
{ - const marker = Object.entries(leafletRefs).find((r) => r[1].item === item)?.[1] - .marker - if (marker) { - navigate(`/${item.id}?${new URLSearchParams(window.location.search)}`) - } else { - navigate( - 'item/' + item.id + '?' + new URLSearchParams(window.location.search), - ) - } - }} - > - {item.layer?.markerIcon?.image ? ( -
- { - code = code.replace(/fill=".*?"/g, 'fill="currentColor"') - code = code.replace(/stroke=".*?"/g, 'stroke="currentColor"') - return code - }} + {itemsResults.slice(0, 5).map((item) => { + // Calculate color using the same logic as PopupView + const itemTags = + item.text + ?.match(/#[^\s#]+/g) + ?.map((tag) => + tags.find((t) => t.name.toLowerCase() === tag.slice(1).toLowerCase()), + ) + .filter(Boolean) ?? [] + + let color1 = item.layer?.markerDefaultColor ?? '#777' + if (item.color) { + color1 = item.color + } else if (itemTags[0]) { + color1 = itemTags[0].color + } + + return ( +
{ + const marker = Object.entries(leafletRefs).find( + (r) => r[1].item === item, + )?.[1].marker + if (marker) { + navigate(`/${item.id}?${new URLSearchParams(window.location.search)}`) + } else { + navigate( + 'item/' + item.id + '?' + new URLSearchParams(window.location.search), + ) + } + }} + > + {item.layer?.markerIcon?.image ? ( +
+ { + code = code.replace(/fill=".*?"/g, 'fill="currentColor"') + code = code.replace(/stroke=".*?"/g, 'stroke="currentColor"') + return code + }} + /> +
+ ) : ( +
-
- ) : ( -
- )} -
-
- {item.name} + )} +
+
+ {item.name} +
+
+ {item.text} +
-
- ))} + ) + })} {Array.from(geoResults).length > 0 && (itemsResults.length > 0 || tagsResults.length > 0) && (
)} {Array.from(geoResults).map((geo) => (
{ @@ -249,19 +278,21 @@ export const SearchControl = () => { hide() }} > - -
+
+ +
+
{geo?.properties.name ? geo?.properties.name : value}
{geo?.properties?.city && `${capitalizeFirstLetter(geo?.properties?.city)}, `}{' '} @@ -281,7 +312,7 @@ export const SearchControl = () => { ))} {isGeoCoordinate(value) && (
{ marker( @@ -306,19 +337,21 @@ export const SearchControl = () => { ) }} > - -
+
+ +
+
{value}
{'Coordiante'}