diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index db3ca29d..5e424b4b 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -74,7 +74,8 @@ export const Layer = ({ popupopen: (e) => { const item = Object.entries(leafletRefs).find(r => r[1].popup == e.popup)?.[1].item; if (item?.layer?.name == name && window.location.pathname.split("/")[2] != item.id) { - window.history.pushState({}, "", `/${name}/${item.id}`) + let params = new URLSearchParams(window.location.search); + window.history.pushState({}, "", `/${name}/${item.id}`+ `${params.toString() !== "" ? `?${params}` : ""}`) let title = ""; if (item.name) title = item.name; else if (item.layer?.itemNameField) title = getValue(item, item.layer.itemNameField); @@ -115,10 +116,6 @@ export const Layer = ({ openPopup(); }, [leafletRefs, location]) - useEffect(() => { - console.log(`all tags loaded: ${allTagsLoaded}`); - }, [allTagsLoaded]) - useEffect(() => { if (tagsReady) { const processedTags = {}; @@ -143,7 +140,7 @@ export const Layer = ({ if (getValue(item, itemLongitudeField) && getValue(item, itemLatitudeField)) { - if (item[itemTextField]) item[itemTextField] = getValue(item, itemTextField); + if (getValue(item, itemTextField)) item[itemTextField] = getValue(item, itemTextField); else item[itemTextField] = ""; if (item?.tags) { item[itemTextField] = item[itemTextField] + '\n\n'; @@ -156,7 +153,7 @@ export const Layer = ({ } - if (allTagsLoaded && allItemsLoaded) { + if (allTagsLoaded && allItemsLoaded) { item[itemTextField].toLocaleLowerCase().match(hashTagRegex)?.map(tag => { if ((!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) && !newTagsToAdd.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) { const newTag = { id: crypto.randomUUID(), name: tag.slice(1).toLocaleLowerCase(), color: randomColor() }; diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index e4c1052e..89084a99 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -61,7 +61,9 @@ export const SearchControl = ({ clusterRef }) => { if (item.layer?.itemTextField) item.text = getValue(item, item.layer.itemTextField) return item.name?.toLowerCase().includes(value.toLowerCase()) || item.text?.toLowerCase().includes(value.toLowerCase()) })) - setTagsResults(tags.filter(tag => tag.name?.toLowerCase().includes(value.toLowerCase()))) + let phrase = value; + if(value.startsWith("#")) phrase = value.substring(1); + setTagsResults(tags.filter(tag => tag.name?.toLowerCase().includes(phrase.toLowerCase()))) }, 500, [value]); @@ -89,13 +91,14 @@ export const SearchControl = ({ clusterRef }) => { {value.length > 0 && } {hideSuggestions || Array.from(geoResults).length == 0 && itemsResults.length == 0 && tagsResults.length == 0 && !isGeoCoordinate(value)|| value.length == 0? "" : -