Class MapInteractionController
- Namespace
- LansMap.Interaction
Built-in pan, zoom, rotate, and pitch input for a ScreenMapView.
public sealed class MapInteractionController : MonoBehaviour
- Inheritance
-
objectObjectComponentBehaviourMonoBehaviourMapInteractionController
Fields
DoubleClickSeconds
Maximum gap between mouse clicks for a double-click zoom, in seconds. 0 disables.
[Tooltip("Double-click zooms in one level at the cursor. 0 disables.")]
public float DoubleClickSeconds
Field Value
FlingDecelDpPerS2
Fling deceleration in density-independent pixels per second squared (dp/s^2).
[Tooltip("Fling deceleration, dp/s^2. Constant stop, not an exponential tail.")]
public double FlingDecelDpPerS2
Field Value
FlingMaxSpeedDp
Fling release speed cap in density-independent pixels per second (dp/s).
[Tooltip("Fling release speed cap, dp/s. Default 1400.")]
public double FlingMaxSpeedDp
Field Value
FlingMinSpeedDp
Release speeds below this, in density-independent pixels per second (dp/s), do not fling.
[Tooltip("Release speeds below this (dp/s) do not fling.")]
public double FlingMinSpeedDp
Field Value
GestureLockThresholdPx
Two-finger travel in density-independent pixels (dp) before the gesture locks to tilt or transform.
[Tooltip("Two-finger travel in dp before the gesture locks to tilt or transform.")]
public float GestureLockThresholdPx
Field Value
InputEnabled
[Header("Input toggles")]
[Tooltip("Master switch for all built-in input handling.")]
public bool InputEnabled
Field Value
InvertQuickZoom
Flips tap-tap-hold drag zoom. Default: drag down zooms in.
[Tooltip("Flip the tap-tap-hold drag direction (default: drag down zooms in).")]
public bool InvertQuickZoom
Field Value
InvertRotateGesture
Flips two-finger rotate direction. Default follows the fingers.
[Tooltip("Flip two-finger rotate direction. Default follows the fingers.")]
public bool InvertRotateGesture
Field Value
InvertTiltGesture
Flips the two-finger tilt direction.
[Tooltip("Flip the two-finger tilt direction (user preference).")]
public bool InvertTiltGesture
Field Value
KeyZoomSpeed
Held-key zoom speed in Web Mercator zoom units per second.
[Tooltip("Zoom levels per second while a zoom key is held.")]
public double KeyZoomSpeed
Field Value
KeyboardEnabled
Enables all key bindings below.
[Tooltip("Enables all key bindings below.")]
public bool KeyboardEnabled
Field Value
Map
Map this controller drives.
[Tooltip("Map this controller drives.")]
public ScreenMapView Map
Field Value
MaxPitchDeg
Maximum tilt in degrees. Values above 85 clamp to 85.
[Tooltip("Maximum tilt in degrees. 85 is a hard cap; higher values clamp to 85. Past 60, turn on the map's Horizon Fade Enabled so the far edge blends into the sky. Past 70 the sub-pixel positioning budget no longer covers raised markers.")]
[Range(0, 85)]
public double MaxPitchDeg
Field Value
Remarks
Defaults to 60, which is where the far edge of the map first
reaches the top of the screen. Past that, turn on
ScreenMapView.HorizonFadeEnabled so the map fades into the
sky instead of ending at a visible line.
Above PrecisionPitchLimitDeg the sub-pixel positioning budget no longer applies. An application that places markers raised above the ground and needs that budget should cap this at that value.
MaxRotateFlingDegPerS
Maximum rotate-fling speed in degrees per second.
[Tooltip("Max rotate-fling speed, deg/s. Default 30.")]
public double MaxRotateFlingDegPerS
Field Value
MaxZoom
Highest zoom the user can reach, in Web Mercator zoom units.
[Tooltip("Highest zoom the user can reach.")]
public double MaxZoom
Field Value
MaxZoomFlingLevels
Maximum zoom levels a pinch fling may add, in Web Mercator zoom units.
[Tooltip("Max zoom levels a pinch fling may add. Default 2.5.")]
public double MaxZoomFlingLevels
Field Value
MinSpanMm
Minimum finger span in millimeters for zoom/rotate. Below this, pan only.
[Tooltip("Minimum finger span in mm for zoom/rotate. Below this, pan only.")]
public float MinSpanMm
Field Value
MinZoom
Lowest zoom the user can reach, in Web Mercator zoom units.
[Tooltip("Lowest zoom the user can reach.")]
public double MinZoom
Field Value
ModifierPitchDegPerPx
Ctrl/Cmd+drag tilt speed in degrees per screen px (vertical).
[Tooltip("Ctrl/Cmd + drag vertical tilt speed in degrees per pixel.")]
public double ModifierPitchDegPerPx
Field Value
ModifierRotateDegPerPx
Ctrl/Cmd+drag rotate speed in degrees per screen px (horizontal).
[Tooltip("Ctrl/Cmd + drag: horizontal rotates, vertical tilts. Degrees per pixel.")]
public double ModifierRotateDegPerPx
Field Value
MouseEnabled
Enables drag pan, scroll zoom, and double-click zoom.
[Tooltip("Enables drag pan, scroll zoom, double-click zoom.")]
public bool MouseEnabled
Field Value
MoveSpeed
Keyboard pan speed in screen px per second for arrow/WASD.
[Tooltip("Screen pixels per second for arrow/WASD panning.")]
public double MoveSpeed
Field Value
PanDownAltKey
Alternate key that pans the map down.
public KeyCode PanDownAltKey
Field Value
- KeyCode
PanDownKey
Key that pans the map down.
public KeyCode PanDownKey
Field Value
- KeyCode
PanLeftAltKey
Alternate key that pans the map left.
public KeyCode PanLeftAltKey
Field Value
- KeyCode
PanLeftKey
Key that pans the map left.
public KeyCode PanLeftKey
Field Value
- KeyCode
PanRightAltKey
Alternate key that pans the map right.
public KeyCode PanRightAltKey
Field Value
- KeyCode
PanRightKey
Key that pans the map right.
public KeyCode PanRightKey
Field Value
- KeyCode
PanUpAltKey
Alternate key that pans the map up.
public KeyCode PanUpAltKey
Field Value
- KeyCode
PanUpKey
Key that pans the map up.
public KeyCode PanUpKey
Field Value
- KeyCode
PitchDownKey
Key that decreases tilt, in degrees.
public KeyCode PitchDownKey
Field Value
- KeyCode
PitchSpeed
Keyboard pitch speed in degrees per second for T/G.
[Tooltip("Degrees per second for T/G.")]
public double PitchSpeed
Field Value
PitchUpKey
Key that increases tilt, in degrees.
public KeyCode PitchUpKey
Field Value
- KeyCode
QuickZoomPerPx
Tap-tap-hold zoom speed in Web Mercator zoom units per density-independent pixel (dp).
[Tooltip("Tap-tap-hold zoom speed, levels per dp. Default 1 per 128 dp.")]
public double QuickZoomPerPx
Field Value
ResetIncludesPosition
When true, the reset key also restores position and zoom, not just rotation and pitch.
[Tooltip("Escape also resets position and zoom, not just rotation and pitch.")]
public bool ResetIncludesPosition
Field Value
ResetViewKey
Key that restores the captured home view.
public KeyCode ResetViewKey
Field Value
- KeyCode
RotateActivateAngleDeg
Two-finger twist angle in degrees, accumulated from gesture start, before rotation starts.
[Tooltip("Two-finger twist angle in degrees before rotation starts. Default 5.")]
public float RotateActivateAngleDeg
Field Value
RotateLeftAltKey
Alternate key that rotates the map counter-clockwise.
public KeyCode RotateLeftAltKey
Field Value
- KeyCode
RotateLeftKey
[Header("Keybinds (rebindable)")]
public KeyCode RotateLeftKey
Field Value
- KeyCode
RotateRightAltKey
Alternate key that rotates the map clockwise.
public KeyCode RotateRightAltKey
Field Value
- KeyCode
RotateRightKey
Key that rotates the map clockwise.
public KeyCode RotateRightKey
Field Value
- KeyCode
RotateSpeed
Keyboard rotate speed in degrees per second for Q/E and [/].
[Tooltip("Degrees per second for Q/E and [/].")]
public double RotateSpeed
Field Value
SingleActionGestures
Locks a two-finger gesture to one action. Off (default) combines pan+zoom with a gated rotate.
[Tooltip("Lock a two-finger gesture to one action. Off (default): pan+zoom, rotate gated.")]
public bool SingleActionGestures
Field Value
TouchDoubleTapSeconds
Maximum gap between one-finger taps for a double-tap zoom, in seconds.
[Tooltip("Max gap between taps for a double-tap. Default 300 ms.")]
public float TouchDoubleTapSeconds
Field Value
TouchEnabled
Enables one-finger pan, pinch zoom, and two-finger rotate and pitch.
[Tooltip("Enables one-finger pan, pinch zoom, two-finger rotate and pitch.")]
public bool TouchEnabled
Field Value
TouchPitchDegPerPx
Two-finger tilt speed in degrees per density-independent pixel (dp).
[Tooltip("Two-finger tilt speed, degrees per dp. Default ~0.3.")]
public double TouchPitchDegPerPx
Field Value
ZoomActivateZoomUnits
Pinch |log2(distance ratio)| in Web Mercator zoom units before zoom starts.
[Tooltip("Pinch |log2(distance ratio)| before zoom starts. Default 0.1 zoom units.")]
public double ZoomActivateZoomUnits
Field Value
ZoomInKey
Key that zooms in while held.
public KeyCode ZoomInKey
Field Value
- KeyCode
ZoomOutKey
Key that zooms out while held.
public KeyCode ZoomOutKey
Field Value
- KeyCode
ZoomSettleRetargetSeconds
[Tooltip("Settle duration used only for a retarget that arrives while a settle is already running (e.g. every frame of a scroll gesture) - short so the map tracks the finger instead of trailing behind it.")]
public double ZoomSettleRetargetSeconds
Field Value
ZoomSettleSeconds
Settle animation duration in seconds. 0 = instant snap at gesture end.
[Tooltip("Settle animation duration in seconds. 0 = instant snap at gesture end.")]
public double ZoomSettleSeconds
Field Value
ZoomSnap
[Header("Zoom snap")]
[Tooltip("Zoom settles to a multiple of this after a gesture, so tiles render 1:1. 1 = whole zoom levels. 0 = zoom rests exactly where the gesture ends.")]
public double ZoomSnap
Field Value
ZoomSpeed
Scroll-wheel zoom step in Web Mercator zoom units per notch.
[Tooltip("Zoom levels per scroll notch.")]
public double ZoomSpeed
Field Value
Properties
InputActive
True this frame while built-in input is driving the map.
public bool InputActive { get; }
Property Value
MinZoomEffective
Lowest zoom the user can reach right now, tightened from MinZoom only while the map's elevation is on.
public double MinZoomEffective { get; }
Property Value
PitchCapDeg
Effective maximum tilt in degrees, clamped to 0..MaxPitchDeg.
public double PitchCapDeg { get; }
Property Value
Remarks
Inspector [Range] does not stop a script or a serialized scene from storing more than MaxPitchDeg. The map rejects pitch above that ceiling, so this property is the cap at point of use.
Methods
CaptureHome()
Stores the current view as the home that ResetView() restores.
public void CaptureHome()
IsPointerOverViewport(Vector2, Rect?, int)
True when a top-left-origin screen point lies inside a camera's viewport rect.
public static bool IsPointerOverViewport(Vector2 screenTopLeftPx, Rect? cameraPixelRect, int screenHeightPx)
Parameters
screenTopLeftPxVector2Pointer position, top-left origin (same convention as IsPointerOverUi(Vector2)).
cameraPixelRectRect?The owning camera's pixelRect (bottom-left origin), or null when there is no camera to test against.
screenHeightPxintScreen height in px, used to flip
screenTopLeftPxinto bottom-left origin.
Returns
ResetView()
Restores rotation and pitch to the last captured home; position and zoom only when ResetIncludesPosition is set.
public void ResetView()
StopInertia()
Stops pan and pinch flings so they do not fight a FlyTo or other animation.
public void StopInertia()