diff options
author | Marcus Lundblad <ml@dfupdate.se> | 2023-05-10 22:06:25 +0200 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2023-05-10 22:35:32 +0200 |
commit | 21d6a2a6f5059ff28437402147d837ee5f5badf8 (patch) | |
tree | 45ff97d3fe2ca6ff350ef7fb2a628312bf98c377 | |
parent | 27c4294271596b3ceafe9dd8ba4d9998399e1e7b (diff) | |
download | gnome-maps-gnome-44.tar.gz |
userLocationMarker: Compensate for map rotationgnome-44
Compensate for the map rotation when drawing the
user location marker (when it has a heading set).
-rw-r--r-- | src/userLocationMarker.js | 12 |
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(); } } |