From 335978d4045312aff1b482f653f171c272d062e3 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 16 Jan 2024 11:25:41 +0100 Subject: [PATCH] place marker for result on geo search --- src/Components/Map/Subcomponents/Controls/SearchControl.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index e2872223..053d2bcd 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -11,6 +11,8 @@ import { useItems } from '../../hooks/useItems'; import { useLeafletRefs } from '../../hooks/useLeafletRefs'; import { getValue } from '../../../../Utils/GetValue'; import { LocateControl } from './LocateControl'; +import * as L from 'leaflet'; +import MarkerIconFactory from '../../../../Utils/MarkerIconFactory'; @@ -121,6 +123,7 @@ export const SearchControl = ({ clusterRef }) => {
{ 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 }) }}> @@ -138,6 +141,7 @@ export const SearchControl = ({ clusterRef }) => {
{ + 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}