summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@dfupdate.se>2023-05-10 22:06:25 +0200
committerMarcus Lundblad <ml@dfupdate.se>2023-05-10 22:06:25 +0200
commitd1c24944e5ec81725767874c36ca6b8f0c87fe9a (patch)
tree8aa23574a0dde89b37cd0f6e21309726578f01fd
parentfdac92185a5f0ebb4328f4e8060a81662c3f1291 (diff)
downloadgnome-maps-wip/mlundblad/fix-rotation-location-marker.tar.gz
userLocationMarker: Compensate for map rotationwip/mlundblad/fix-rotation-location-marker
Compensate for the map rotation when drawing the user location marker (when it has a heading set).
-rw-r--r--src/userLocationMarker.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index 26fcc8d4..fbc4a851 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -98,6 +98,8 @@ export class UserLocationMarker extends MapMarker {
this._updateLocation();
this.connect('notify::visible', this._updateAccuracyCircle.bind(this));
+ this._mapView.map.viewport.connect('notify::rotation',
+ () => this._updateLocation());
}
_hasBubble() {
@@ -129,20 +131,26 @@ export class UserLocationMarker extends MapMarker {
}
vfunc_snapshot(snapshot) {
+ snapshot.save();
+
if (this.place.location.heading > -1) {
// rotate around the center of the icon
- let {x, y, width, height} = this.get_allocation();
+ let width = this.get_width();
+ let height = this.get_height();
let point = new Graphene.Point();
+ let rotation = this.place.location.heading +
+ this._mapView.map.viewport.rotation * 180 / Math.PI;
point.init(width / 2, height / 2);
snapshot.translate(point);
- snapshot.rotate(this.place.location.heading);
+ snapshot.rotate(rotation);
point.init(-width / 2, -height / 2);
snapshot.translate(point);
}
this.snapshot_child(this._image, snapshot);
super.vfunc_snapshot(snapshot);
+ snapshot.restore();
}
}