Table of Contents

Class BaseMapView

Namespace
LansMap.Map.Views
Assembly
LansMap.Runtime.dll
public abstract class BaseMapView : MonoBehaviour
Inheritance
object
Object
Component
Behaviour
MonoBehaviour
BaseMapView
Derived

Fields

AltitudeScale

[Tooltip("Visual multiplier for marker altitudes. 1 = true scale, 0.001 = compress 10 km to 10 m.")]
public double AltitudeScale

Field Value

double

DefaultPlaneDistance

Default PlaneDistance, in Unity world units.

public const float DefaultPlaneDistance = 5

Field Value

float

ElevationSource

Terrain heights this map fetches, instead of the built-in Terrarium tiles. Set it before Start. Null lets an attached MapElevationSourceComponent, or the built-in source, decide.

[NonSerialized]
public IElevationSource ElevationSource

Field Value

IElevationSource

Remarks

Read only when elevation is on. The map owns the lifecycle around the source: when to fetch, when to re-fetch as the view moves, and disposing what it produced.

FrameBudgetMs

[Tooltip("Total per-frame ms shared across tile upload, cluster build, and marker warm-up work-spreading. Read once, at FrameBudget's first access.")]
public double FrameBudgetMs

Field Value

double

InputSource

Mouse, keyboard and touch this map's built-in tools read. Set it before Start to drive the map from your own input stack, or from a test with no live device. Null lets an attached MapInputSourceComponent, or Unity's own devices, answer.

[NonSerialized]
public IMapInputSource InputSource

Field Value

IMapInputSource

Latitude

[Tooltip("View center latitude in degrees (WGS84).")]
public double Latitude

Field Value

double

Longitude

[Tooltip("View center longitude in degrees (WGS84).")]
public double Longitude

Field Value

double

PlaneDistance

[Tooltip("Distance from the camera, in Unity world units, at which prefab-tier markers and LatLonToWorld are placed.")]
public float PlaneDistance

Field Value

float

RotationDeg

[Tooltip("Map bearing in degrees, counterclockwise.")]
public double RotationDeg

Field Value

double

TileDependencies

Tile source, address builder, fetcher, tile store and codecs this map runs on, instead of a provider preset.

[NonSerialized]
public TilePipelineDependencies TileDependencies

Field Value

TilePipelineDependencies

Remarks

Set it before Start, or call SetTileDependencies(TilePipelineDependencies) afterwards. Null lets the inspector's provider (or an attached MapTileDependenciesComponent) decide.

TileFilterMode

[Tooltip("Sampling for map tiles. Automatic uses trilinear with mip chains and bilinear without them. Point is a sharp but aliased diagnostic. Applied when the pipeline builds.")]
public TileFilterMode TileFilterMode

Field Value

TileFilterMode

TileFloorPinEnabled

[Tooltip("Keep those world tiles in GPU memory once loaded, so zooming out is instant. Can change while running.")]
public bool TileFloorPinEnabled

Field Value

bool

TileFloorPinMaxZoom

[Tooltip("Deepest zoom of that pinned world slice. 4 = 341 tiles. A request, not a guarantee. Set before Play.")]
public int TileFloorPinMaxZoom

Field Value

int

WebAstcQuality

[Tooltip("Browser ASTC tile encoder search effort. Higher values improve raster detail but reduce worker tile throughput. Applied when the pipeline builds.")]
public WebAstcEncoderQuality WebAstcQuality

Field Value

WebAstcEncoderQuality

Zoom

[Tooltip("Fractional map zoom level (Web Mercator).")]
public double Zoom

Field Value

double

Properties

Camera

The camera LatLonToWorld(LatLon) poses against when no bound PrefabMarkerManager overrides it with its own TargetCamera.

public virtual Camera Camera { get; }

Property Value

Camera

Remarks

Not cached: the default resolves Camera.main on every read, a live lookup, so a consumer that swaps the active main camera at runtime is picked up on the next call rather than going stale.

CurrentView

The transform answering every projection question for this view this frame; cached by the subclass, never allocate per read.

public abstract MapViewTransform CurrentView { get; }

Property Value

MapViewTransform

DefaultPointerSurface

The real screen, read through this map's input source. What a tool falls back to when its own pointer surface is unset.

public IMapPointerSurface DefaultPointerSurface { get; }

Property Value

IMapPointerSurface

EffectiveInputSource

The mouse, keyboard and touch this map actually runs on. Never null.

public IMapInputSource EffectiveInputSource { get; }

Property Value

IMapInputSource

Remarks

Resolved on the first read and held for the map's lifetime: assign InputSource, or attach your component, before anything drives the map.

ElevationSampler

Ground height source this view's live terrain fetch has resolved, or null for a flat map (elevation off, or no live fetch has landed yet).

public abstract IElevationSampler ElevationSampler { get; }

Property Value

IElevationSampler

Remarks

Both subclasses build through the one TilePipelineHost elevation fetch/lifecycle and forward its ElevationTileSet.Sampler here - one data source for whichever render mechanism each subclass actually uses (a displaced tile mesh on a fullscreen map, a world-space mesh draped over a tabletop's flat texture).

FrameBudget

One shared per-frame time budget for the mechanics that spread their own work across several frames: tile upload, cluster build, and marker warm-up.

public CooperativeFrameBudget FrameBudget { get; }

Property Value

CooperativeFrameBudget

Info

Marker metadata (name, hover text, per-marker style), one store per view, always present.

public MarkerInfoStore Info { get; }

Property Value

MarkerInfoStore

Labels

Marker label tier; see Markers for the null contract.

public MarkerLabelLayer Labels { get; protected set; }

Property Value

MarkerLabelLayer

LayerStack

The ordered layer stack (named layers plus externally-registered overlays) this view draws every frame - see RegisterExternalOverlay(IMapScreenSpaceOverlay, int).

protected abstract MapLayerStack LayerStack { get; }

Property Value

MapLayerStack

Remarks

Each subclass owns a different concrete draw path (ScreenMapView through its MapDrawCoordinator, SurfaceMapView through its own render-into-texture loop), so this exposes whichever MapLayerStack instance actually backs it rather than assuming one shared implementation.

Markers

Bulk marker tier; non-null on both shipped map types from the moment the component exists.

public virtual MarkerLayer Markers { get; protected set; }

Property Value

MarkerLayer

Remarks

ScreenMapView builds it in Awake; SurfaceMapView creates it lazily on first read. Virtual so a subclass may choose either.

PlaceLabels

Vector place-name tier; see Markers for the null contract.

public PlaceLabelLayer PlaceLabels { get; protected set; }

Property Value

PlaceLabelLayer

Polygons

Polygon tier; see Markers for the lifetime contract.

public virtual PolygonLayer Polygons { get; protected set; }

Property Value

PolygonLayer

Polylines

Polyline tier; see Markers for the lifetime contract.

public virtual PolylineLayer Polylines { get; protected set; }

Property Value

PolylineLayer

Prefabs

The PrefabMarkerManager driving this view's prefab marker tier, or null if none has registered. Unlike Markers, this view does not build it: the manager registers itself via RegisterPrefabs(PrefabMarkerManager).

public PrefabMarkerManager Prefabs { get; }

Property Value

PrefabMarkerManager

Methods

ApplyTileDependencies()

protected virtual void ApplyTileDependencies()

FloorPinCapacityFloor()

protected int FloorPinCapacityFloor()

Returns

int

GetCorners()

The lat/lon under the view's top-left and bottom-right screen corners.

public (LatLon TopLeft, LatLon BottomRight) GetCorners()

Returns

(LatLon TopLeft, LatLon BottomRight)

The two corners, following ScreenToLatLon(Vector2)'s own bottom-left-origin, Y-up screen convention.

Remarks

The two screen corners, not a rotation-independent bounding box: at a nonzero RotationDeg the map is no longer north-up on screen, so TopLeft is not guaranteed to be north/west of BottomRight.

LatLonToScreen(double, double)

Projects a geographic coordinate to its position in the view's pixels (see ScreenToLatLon(Vector2) for the convention), following the nearest-copy rule under world wrap the same way tiles and markers draw; may legitimately lie outside the viewport.

public Vector2 LatLonToScreen(double lat, double lon)

Parameters

lat double
lon double

Returns

Vector2

LatLonToWorld(LatLon)

The world position at would sit at this frame, at ground level.

public Vector3 LatLonToWorld(LatLon at)

Parameters

at LatLon

Geographic position.

Returns

Vector3

World position; never fails geometrically.

Remarks

See LatLonToWorld(LatLonAltitude) for the full contract.

Exceptions

InvalidOperationException

See LatLonToWorld(LatLonAltitude): no camera resolved.

LatLonToWorld(LatLonAltitude)

The world position at would sit at this frame, for any coordinate and any altitude, with no bound PrefabMarkerManager needed.

public Vector3 LatLonToWorld(LatLonAltitude at)

Parameters

at LatLonAltitude

Geographic position and altitude, resolved the same way Prefabs.Spawn resolves it by default (RelativeToGround): meters above sampled ground, or above the flat reference plane when elevation is off or unsampled.

Returns

Vector3

World position. Valid for this frame only: a re-anchor, pan, zoom, or tilt moves it. On a perspective pose camera, finite for every input, including a point behind the camera or past the far view-distance cap - the map does not draw ground past that cap, so a caller that draws something at the returned position there is drawing off the map. An orthographic pose camera has no "behind the camera" plane in the perspective sense; see ToWorld(Camera, ViewSpacePoint, float) for what it returns there.

Remarks

Poses on a bound PrefabMarkerManager's table plane when one is bound and its plane is valid (same dispatch TryPoseWorldPosition uses); a table pose that fails for its own reasons (no plane yet) falls back to the screen path below rather than surfacing that as a caller-visible failure.

Exceptions

InvalidOperationException

No camera resolved: neither a bound manager's TargetCamera nor Camera (which, on the default implementation, falls back to Camera.main) resolved one. This is a scene configuration bug, not a geometric failure, so it throws rather than returning a sentinel.

RaiseViewChanged(MapViewChange)

Raises ViewChanged. Called by the concrete view type from its own firing logic.

protected void RaiseViewChanged(MapViewChange change)

Parameters

change MapViewChange

Snapshot of the view state that changed.

RaiseViewChangedDetailed(MapViewChangedFields)

Raises ViewChangedDetailed. Called by the concrete view type at the same site as RaiseViewChanged(MapViewChange).

protected void RaiseViewChangedDetailed(MapViewChangedFields changedFields)

Parameters

changedFields MapViewChangedFields

Which fields moved this frame.

RefuseProviderChangeWithTileDependencies()

protected void RefuseProviderChangeWithTileDependencies()

RegisterExternalOverlay(IMapScreenSpaceOverlay, int)

Registers an externally-owned screen-space overlay (e.g. a MarkerClusterController) to draw at order in this view's layer stack, in the same order on either concrete view type.

public virtual void RegisterExternalOverlay(IMapScreenSpaceOverlay overlay, int order = 70000)

Parameters

overlay IMapScreenSpaceOverlay

Overlay to draw every frame until unregistered.

order int

A MapDrawOrder value; defaults to AboveExternalOverlays, the position every overlay drew at before per-overlay ordering existed. Registering the same overlay again updates its order.

RegisterPrefabs(PrefabMarkerManager)

Registers manager as the one exposed through Prefabs.

public void RegisterPrefabs(PrefabMarkerManager manager)

Parameters

manager PrefabMarkerManager

The manager to expose as Prefabs.

Remarks

Called by the manager itself, not by map consumers. Last-registered-wins when more than one manager targets the same view.

ResolveElevationSource()

protected IElevationSource ResolveElevationSource()

Returns

IElevationSource

ResolveTileDependencies()

protected TilePipelineDependencies ResolveTileDependencies()

Returns

TilePipelineDependencies

ResolvedElevationCoverageTiles()

The resolved elevation coverage tiles for this view, from the current view location and zoom; null if elevation is off.

protected abstract IEnumerable<TileCoord> ResolvedElevationCoverageTiles()

Returns

IEnumerable<TileCoord>

Remarks

Used by drift detection and the pipeline's initial build.

ScreenToLatLon(Vector2)

Unprojects a view position to a geographic coordinate, through the same double-precision re-anchored affine the renderer itself uses.

public LatLon ScreenToLatLon(Vector2 viewPx)

Parameters

viewPx Vector2

Position in the view's pixels, origin bottom left, Y increasing upward (Unity's Input.mousePosition convention). Screen pixels on a fullscreen map, render-texture pixels on a surface.

Returns

LatLon

Remarks

This method and LatLonToScreen(double, double) are not exact inverses once the world repeats: this one wraps its result to the home copy, that one follows the nearest-copy rule. A round trip is an identity only within half a world copy of the view center.

SetTileDependencies(TilePipelineDependencies)

Hands the map a new set of tile dependencies: before Start it just records them, afterwards it tears the tile pipeline down and rebuilds on them, the same lifecycle a provider switch has.

public void SetTileDependencies(TilePipelineDependencies dependencies)

Parameters

dependencies TilePipelineDependencies

The new bundle, or null to hand the map back to its inspector provider.

TryLatLonToWorld(double, double, double, out Vector3)

Overload of TryLatLonToWorld(double, double, out Vector3) with an explicit altitude, resolved the same way Prefabs.Spawn resolves it by default (RelativeToGround): meters above sampled ground, or above the flat reference plane when elevation is off or unsampled.

public bool TryLatLonToWorld(double lat, double lon, double altitudeMeters, out Vector3 world)

Parameters

lat double

Latitude in degrees WGS84.

lon double

Longitude in degrees WGS84.

altitudeMeters double

Altitude in meters, relative to ground.

world Vector3

World position on success; default otherwise.

Returns

bool

See TryLatLonToWorld(double, double, out Vector3).

TryLatLonToWorld(double, double, out Vector3)

The world-space position a prefab-tier marker spawned at this coordinate, at ground level, would be posed at THIS FRAME.

public bool TryLatLonToWorld(double lat, double lon, out Vector3 world)

Parameters

lat double

Latitude in degrees WGS84.

lon double

Longitude in degrees WGS84.

world Vector3

World position on success; default otherwise.

Returns

bool

False in the same cases a marker's own per-frame reposition skips it (a degenerate perspective term, or no camera yet).

Remarks

Valid for the current frame only: a re-anchor, pan, zoom, or tilt changes it. Either recompute it in your own Update or ViewChanged handler, or - for content that should just stay pinned to the map - parent it under Prefabs.Spawn(...) and let the prefab marker tier reproject it every frame instead of calling this yourself each frame. Ground level here means altitude 0 under RelativeToGround, the same default Prefabs.Spawn resolves altitude 0 against.

UnregisterExternalOverlay(IMapScreenSpaceOverlay)

public virtual void UnregisterExternalOverlay(IMapScreenSpaceOverlay overlay)

Parameters

overlay IMapScreenSpaceOverlay

Overlay to stop drawing.

UnregisterPrefabs(PrefabMarkerManager)

Clears Prefabs if manager is still the one registered.

public void UnregisterPrefabs(PrefabMarkerManager manager)

Parameters

manager PrefabMarkerManager

The manager that is tearing down.

Remarks

A manager that already lost the registration leaves Prefabs untouched.

Events

ViewChanged

Fires at most once per frame when the view moved. Which fields are compared, and from which Unity callback, is documented on the concrete view type.

public event Action<MapViewChange> ViewChanged

Event Type

Action<MapViewChange>

ViewChangedDetailed

Fires alongside ViewChanged (same frame, same at-most-once-per-frame rule) naming which fields moved.

public event Action<MapViewChangedFields> ViewChangedDetailed

Event Type

Action<MapViewChangedFields>

Remarks

A user zoom-on-point gesture usually moves the center too, so it typically reports Zoom | Position together, not Zoom alone. Same frame-volatile semantics as ViewChanged: read the flags synchronously in the handler, do not cache them past the current frame. A frame that moves only a field with no flag of its own (AltitudeScale, the tile display size) still fires, carrying None - so treat None as "the view changed in some other way", never as "nothing changed".