Skip to content

Commit

Permalink
store/restore rotation correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Feb 22, 2024
1 parent e03c045 commit f7a9629
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ class MainFragment :
binding.locationPointerPin.isGone = intersectionPosition == null
if (intersectionPosition != null) {
val angleAtIntersection = position.initialBearingTo(intersectionPosition)
binding.locationPointerPin.pinRotation = angleAtIntersection.toFloat() + (180 * rotation / PI).toFloat()
binding.locationPointerPin.pinRotation = (angleAtIntersection + rotation).toFloat()

val a = angleAtIntersection * PI / 180f + rotation
val a = (angleAtIntersection + rotation) * PI / 180f
val offsetX = (sin(a) / 2.0 + 0.5) * binding.locationPointerPin.width
val offsetY = (-cos(a) / 2.0 + 0.5) * binding.locationPointerPin.height
binding.locationPointerPin.x = intersection.x - offsetX.toFloat()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class MainMapFragment : LocationAwareMapFragment(), ShowsGeometryMarkers {
// is it definitely a maplibre issue? or maybe some map change listener?
// any way tp get useful stack traces from maplibre? often it just starts at Handler.dispatchMessage, so no idea which line of SC triggered it
// re-arrange things so things can be added via mapController instead of doing everything here and with MainActivity
// rotation not stored / restored correctly on startup (but location is)
// when tilt is used and map is scrolled up far enough, pointer pin points 180° wrong
// gps and user tracks not working (why?)
// created features seem correct, but also not added to other layers (e.g. putting into geometrySource)
// downloadedAreaMapComponent not working (why?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class CameraManager(private val mapboxMap: MapboxMap, private val contentResolve

class CameraUpdate {
var position: LatLon? = null
var rotation: Double? = null
var tilt: Double? = null
var rotation: Double? = null // degrees
var tilt: Double? = null // degrees
var zoom: Double? = null

var zoomBy: Double? = null
Expand All @@ -70,7 +70,7 @@ data class ScCameraPosition(
) {
constructor(p: CameraPosition) : this(
p.target?.toLatLon() ?: LatLon(0.0, 0.0),
-p.bearing * PI / 180.0,
-p.bearing,
p.tilt,
p.zoom
)
Expand Down

0 comments on commit f7a9629

Please sign in to comment.