diff options
author | Anton Tananaev <anton@traccar.org> | 2023-09-07 21:10:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-09-07 21:10:33 -0700 |
commit | f87566f0bdc7837cf6ac33eadecced1160d019bf (patch) | |
tree | a8ba650ba286fc60dc38fe6c4227f37fd862b9e7 /modern/src/map | |
parent | daaac27d4ddc934f90cc75d64dbc83a61db77cd4 (diff) | |
download | trackermap-web-f87566f0bdc7837cf6ac33eadecced1160d019bf.tar.gz trackermap-web-f87566f0bdc7837cf6ac33eadecced1160d019bf.tar.bz2 trackermap-web-f87566f0bdc7837cf6ac33eadecced1160d019bf.zip |
Fix selected position click
Diffstat (limited to 'modern/src/map')
-rw-r--r-- | modern/src/map/MapPositions.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modern/src/map/MapPositions.js b/modern/src/map/MapPositions.js index e47f945c..751c61b9 100644 --- a/modern/src/map/MapPositions.js +++ b/modern/src/map/MapPositions.js @@ -140,6 +140,10 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF 'icon-rotation-alignment': 'map', }, }); + + map.on('mouseenter', source, onMouseEnter); + map.on('mouseleave', source, onMouseLeave); + map.on('click', source, onMarkerClick); }); map.addLayer({ id: clusters, @@ -155,20 +159,14 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF }, }); - map.on('mouseenter', id, onMouseEnter); - map.on('mouseleave', id, onMouseLeave); map.on('mouseenter', clusters, onMouseEnter); map.on('mouseleave', clusters, onMouseLeave); - map.on('click', id, onMarkerClick); map.on('click', clusters, onClusterClick); map.on('click', onMapClick); return () => { - map.off('mouseenter', id, onMouseEnter); - map.off('mouseleave', id, onMouseLeave); map.off('mouseenter', clusters, onMouseEnter); map.off('mouseleave', clusters, onMouseLeave); - map.off('click', id, onMarkerClick); map.off('click', clusters, onClusterClick); map.off('click', onMapClick); @@ -177,6 +175,10 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF } [id, selected].forEach((source) => { + map.off('mouseenter', source, onMouseEnter); + map.off('mouseleave', source, onMouseLeave); + map.off('click', source, onMarkerClick); + if (map.getLayer(source)) { map.removeLayer(source); } |