Class MapFollowController
- Namespace
- LansMap.Interaction
- Assembly
- LansMap.Runtime.dll
Keeps a map centered on a moving IMapFollowTarget, with optional heading-up rotation, screen offset, and smoothing. Either channel can be switched off: FollowPosition false with RotateWithHeading true turns the map with the target's heading and leaves the center where it is.
[DefaultExecutionOrder(-50)]
public sealed class MapFollowController : MonoBehaviour
- Inheritance
-
objectObjectComponentBehaviourMonoBehaviourMapFollowController
Remarks
A follow-driven move raises the map's ViewChanged event on the
next frame, the same as any other programmatic write.
Fields
FollowPosition
Moves the map center to the target. Off leaves the center alone, so only RotateWithHeading moves the view.
[Tooltip("Move the map center to the target. Off follows heading only.")]
public bool FollowPosition
Field Value
Map
Map this controller moves.
[Tooltip("Map this controller moves.")]
public BaseMapView Map
Field Value
RotateWithHeading
Rotates the map so the target's heading points up the screen.
[Tooltip("Rotate the map so the target's heading points up the screen.")]
public bool RotateWithHeading
Field Value
RotationOffsetDeg
Added to the target heading when RotateWithHeading is on, in degrees. Ignored while it is off.
[Tooltip("Added to the target heading when RotateWithHeading is on, degrees.")]
public double RotationOffsetDeg
Field Value
ScreenOffsetPx
Where the target sits relative to the view center, in view pixels
(x right, y up, the same frame BaseMapView.LatLonToScreen
returns). Zero keeps it centered; a negative y puts it low on
screen like a navigation app. Ignored while FollowPosition
is off, since placing the target on screen needs a moving center.
[Tooltip("Where the target sits relative to the view center, in view pixels (x right, y up). Zero keeps it centered; a negative y puts it low on screen like a navigation app. Ignored while FollowPosition is off.")]
public Vector2 ScreenOffsetPx
Field Value
- Vector2
SmoothSeconds
Seconds to settle after the target moves. 0 or less snaps every frame.
[Tooltip("Seconds to settle after the target moves. 0 snaps every frame.")]
public float SmoothSeconds
Field Value
StopOnUserDrag
Stops following when the user starts dragging the map.
[Tooltip("Stop following when the user starts dragging the map.")]
public bool StopOnUserDrag
Field Value
Properties
IsFollowing
Whether this controller currently has a target.
public bool IsFollowing { get; }
Property Value
Target
The object being followed; null when idle.
public IMapFollowTarget Target { get; }
Property Value
Methods
Follow(IMapFollowTarget)
Starts following. Cancels an in-flight FlyTo. Replaces any current target.
public void Follow(IMapFollowTarget target)
Parameters
targetIMapFollowTargetObject to follow.
Remarks
Logs a warning and does nothing on every call while Map is null.
Stop()
Stops following; the view stays where it is.
public void Stop()
Events
Started
Fires when Follow(IMapFollowTarget) starts following a target.
public event Action<IMapFollowTarget> Started
Event Type
Stopped
Fires when following stops: Stop(), a dead target, or a lost map.
public event Action<IMapFollowTarget> Stopped