From 8909ea906d452bff353a7d5e1a9b1edd81a9b942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Kiripolszky?= Date: Tue, 12 Dec 2023 23:29:27 +0100 Subject: [PATCH] Rotate map icon instead of view (#3668) --- src/js/tabs/map.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/js/tabs/map.js b/src/js/tabs/map.js index 7df28f2570..3b17bbe933 100644 --- a/src/js/tabs/map.js +++ b/src/js/tabs/map.js @@ -103,13 +103,11 @@ function processMapEvents(e) { case 'center': case 'centerMag': - const iconStyle = e.data.action == 'centerMag' ? iconStyleMag : iconStyleGPS; - iconFeature.setStyle(iconStyle); + const hasMag = e.data.action == 'centerMag'; + (hasMag ? iconStyleMag : iconStyleGPS).getImage().setRotation(e.data.heading); + iconFeature.setStyle(hasMag ? iconStyleMag : iconStyleGPS); const center = ol.proj.fromLonLat([e.data.lon, e.data.lat]); mapView.setCenter(center); - // TODO - add rotation for the icon - // const heading = e.data.heading === undefined ? 0 : e.data.heading; - // mapView.setRotation(heading); iconGeometry.setCoordinates(center); break;