From c675cf36eed0df4f5beabdf668baf27e88426303 Mon Sep 17 00:00:00 2001 From: Inga Date: Sun, 19 Nov 2023 13:40:38 +0000 Subject: [PATCH] simplified circle labels --- .../useMarkersOnMap/getLayersForMarkers.ts | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/routePlanner/hooks/useMarkersOnMap/getLayersForMarkers.ts b/src/routePlanner/hooks/useMarkersOnMap/getLayersForMarkers.ts index fda153f..3a80afc 100644 --- a/src/routePlanner/hooks/useMarkersOnMap/getLayersForMarkers.ts +++ b/src/routePlanner/hooks/useMarkersOnMap/getLayersForMarkers.ts @@ -24,26 +24,20 @@ export const getLayersForMarkers = ( ]; }), // circles and labels - ...markers.flatMap((marker) => { - const circle = leaflet.circleMarker(marker.coordinates, { - ...markerLayersStyle, - bubblingMouseEvents: false, - fill: true, - fillOpacity: 100, - }); - const tooltip = leaflet - .tooltip( - { - permanent: true, - direction: 'center', - className: 'text', - content: marker.shortLabel, - }, - circle, - ) - .setLatLng(marker.coordinates); - - circle.on('click', marker.remove); - return [circle, tooltip]; - }), + ...markers.map((marker) => + leaflet + .circleMarker(marker.coordinates, { + ...markerLayersStyle.circleStyle, + bubblingMouseEvents: false, + fill: true, + fillOpacity: 100, + }) + .on('click', marker.remove) + .bindTooltip(marker.shortLabel, { + permanent: true, + direction: 'center', + className: 'text', + content: marker.shortLabel, + }), + ), ];