From f74c352e4498fb94b1078cf3b5523b6114e69b7a Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 16 Jan 2024 11:35:29 +0100 Subject: [PATCH] fixed search result marker popup --- .../Subcomponents/Controls/SearchControl.tsx | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 053d2bcd..3adba36a 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -115,18 +115,17 @@ export const SearchControl = ({ clusterRef }) => { ))} {Array.from(geoResults).length > 0 && (itemsResults.length > 0 || tagsResults.length > 0) &&
} {Array.from(geoResults).map((geo) => ( -
+
{ + searchInput.current?.blur(); + L.marker(new LatLng(geo.geometry.coordinates[1], geo.geometry.coordinates[0]),{icon: MarkerIconFactory("circle", "#777", "RGBA(35, 31, 32, 0.2)", "circle-solid")}).addTo(map).bindPopup(`

${geo?.properties.name ? geo?.properties.name : value}

${capitalizeFirstLetter(geo?.properties?.osm_value)}`).openPopup().addEventListener("popupclose", (e) => {console.log(e.target.remove())}); + if (geo.properties.extent) map.fitBounds(new LatLngBounds(new LatLng(geo.properties.extent[1], geo.properties.extent[0]), new LatLng(geo.properties.extent[3], geo.properties.extent[2]))); + else map.setView(new LatLng(geo.geometry.coordinates[1], geo.geometry.coordinates[0]), 15, { duration: 1 }) + }}> -
{ - searchInput.current?.blur(); - L.marker(new LatLng(geo.geometry.coordinates[1], geo.geometry.coordinates[0]),{icon: MarkerIconFactory("circle", "#777", "RGBA(35, 31, 32, 0.2)", "circle-solid")}).addTo(map).bindPopup(`

${value}

${capitalizeFirstLetter(geo?.properties?.osm_value)}`).openPopup().addEventListener("popupclose", (e) => {console.log(e.target.remove())}); - if (geo.properties.extent) map.fitBounds(new LatLngBounds(new LatLng(geo.properties.extent[1], geo.properties.extent[0]), new LatLng(geo.properties.extent[3], geo.properties.extent[2]))); - else map.setView(new LatLng(geo.geometry.coordinates[1], geo.geometry.coordinates[0]), 15, { duration: 1 }) - }}> +
{geo?.properties.name ? geo?.properties.name : value}
{geo?.properties?.city && `${capitalizeFirstLetter(geo?.properties?.city)}, `} {geo?.properties?.osm_value && geo?.properties?.osm_value !== "primary" && geo?.properties?.osm_value !== "path" && geo?.properties?.osm_value !== "secondary" && geo?.properties?.osm_value !== "residential" && geo?.properties?.osm_value !== "unclassified" && `${capitalizeFirstLetter(geo?.properties?.osm_value)}, `} {geo.properties.state && `${geo.properties.state}, `} {geo.properties.country && geo.properties.country}
@@ -134,16 +133,15 @@ export const SearchControl = ({ clusterRef }) => { ))} {isGeoCoordinate(value) && -
+
{ + L.marker(new LatLng(extractCoordinates(value)![0], extractCoordinates(value)![1]),{icon: MarkerIconFactory("circle", "#777", "RGBA(35, 31, 32, 0.2)", "circle-solid")}).addTo(map).bindPopup(`

${extractCoordinates(value)![0]}, ${extractCoordinates(value)![1]}

`).openPopup().addEventListener("popupclose", (e) => {console.log(e.target.remove())}); + map.setView(new LatLng(extractCoordinates(value)![0], extractCoordinates(value)![1]), 15, { duration: 1 }) + }}> -
{ - L.marker(new LatLng(extractCoordinates(value)![0], extractCoordinates(value)![1]),{icon: MarkerIconFactory("circle", "#777", "RGBA(35, 31, 32, 0.2)", "circle-solid")}).addTo(map).bindPopup(`

${extractCoordinates(value)![0]}, ${extractCoordinates(value)![1]}

`).openPopup().addEventListener("popupclose", (e) => {console.log(e.target.remove())}); - map.setView(new LatLng(extractCoordinates(value)![0], extractCoordinates(value)![1]), 15, { duration: 1 }) - }}> +
{value}
{"Coordiante"}