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, + }), + ), ];