Skip to content

geo.viewport.camera

9 functions / 7 types

Index

FunctionDescription
flyToAnimate one viewport to a position on a map, acquiring geographic camera control. Zero duration places the camera on the next frame. An omitted duration uses three seconds. A flight to another map crosses on the globe and lands in the view the camera set out in. A flight asked for during a switch between the views starts at once, and the switch carries the camera to it.
getClearanceRead how near one viewport camera comes to drawn geometry, in meters, as geo.viewport.camera.set_clearance describes it.
getFlightRead how far the last flight geo.viewport.camera.fly_to sent a viewport on has come.
getLocationRead where one viewport camera stands over the map, and the ground under the middle of its view.
getZoomOutLimitRead how far one viewport camera zooms out from the globe, as geo.viewport.camera.set_zoom_out_limit describes it.
orbitToFails unless longitude and latitude name a place. Turn viewport cameras about the ground in the middle of their view, which stays in the middle all the way, to look at it from a new heading, pitch or range.
setClearanceSet how near viewport cameras come to drawn geometry, in meters.
setZoomOutLimitSet how far viewport cameras zoom out from the globe, as the share of the view’s height the body’s disc spans where a zoom out stops.
zoomByZoom viewport cameras toward the middle of their view by a number of scroll wheel notches.
TypeDescription
CameraDestination
CameraPoseCamera placement in geographic coordinates.
CameraTargetPosition the camera and its target explicitly. Up follows the displayed map normal at the eye. Coincident positions fail. A vertical view uses the local east direction to fix roll.
CameraViewWhere a camera stands over the map.
FlightStageHow far a flight from one map’s body to another has come.
FlightStateThe last flight a camera was sent on with geo.viewport.camera.fly_to.
LookAtFrame a geographic target from a range in meters. A camera in the flat view lands straight over the target at the range with north up, whatever heading and pitch are asked for.

flyTo

flyTo(args: { destination: GeoViewportCameraCameraDestination; durationSeconds?: number; map: SceneNode; viewport?: string }, transactionId?: string): Promise<void>

Animate one viewport to a position on a map, acquiring geographic camera control. Zero duration places the camera on the next frame. An omitted duration uses three seconds. A flight to another map crosses on the globe and lands in the view the camera set out in. A flight asked for during a switch between the views starts at once, and the switch carries the camera to it.

Returns Promise<void>.

durationSeconds optional : number

map : SceneNode

viewport optional : string

transactionId optional : string

getClearance

getClearance(args?: { viewport?: string }, transactionId?: string): Promise<number>

Read how near one viewport camera comes to drawn geometry, in meters, as geo.viewport.camera.set_clearance describes it.

Fails unless exactly one viewport matches viewport.

Returns Promise<number>.

viewport optional : string

Label of the viewport to read. Absent, the only viewport is read.

transactionId optional : string

getFlight

getFlight(args?: { viewport?: string }, transactionId?: string): Promise<GeoViewportCameraFlightState | undefined>

Read how far the last flight geo.viewport.camera.fly_to sent a viewport on has come.

Returns nothing when the viewport’s camera was never sent on one. Fails unless exactly one viewport matches viewport.

Returns Promise<GeoViewportCameraFlightState | undefined>.

viewport optional : string

Label of the viewport to read. Absent, the only viewport is read.

transactionId optional : string

getLocation

getLocation(args?: { viewport?: string }, transactionId?: string): Promise<GeoViewportCameraCameraView | undefined>

Read where one viewport camera stands over the map, and the ground under the middle of its view.

The reading uses the conventions geo.viewport.camera.fly_to takes, so passing it back puts the camera where it was. Returns nothing before the map has been built. Fails unless exactly one viewport matches viewport.

Returns Promise<GeoViewportCameraCameraView | undefined>.

viewport optional : string

Label of the viewport to read. Absent, the only viewport is read.

transactionId optional : string

getZoomOutLimit

getZoomOutLimit(args?: { viewport?: string }, transactionId?: string): Promise<number>

Read how far one viewport camera zooms out from the globe, as geo.viewport.camera.set_zoom_out_limit describes it.

Fails unless exactly one viewport matches viewport.

Returns Promise<number>.

viewport optional : string

Label of the viewport to read. Absent, the only viewport is read.

transactionId optional : string

orbitTo

orbitTo(args?: { durationSeconds?: number; heading?: number; pitch?: number; rangeScale?: number; viewport?: string }, transactionId?: string): Promise<void>

Fails unless longitude and latitude name a place. Turn viewport cameras about the ground in the middle of their view, which stays in the middle all the way, to look at it from a new heading, pitch or range.

The cameras read where they stand and what they look at themselves, so a caller does not pass back a reading that may be a frame old. The heading and pitch ease from where they are, the heading the short way round, and the range evenly in its logarithm, starting and ending at rest. Fails where the middle of a view shows no ground, and in the flat view, which only pans and zooms.

Returns Promise<void>.

durationSeconds optional : number

How long the turn takes. Zero turns at once on the next frame. Absent, three seconds.

heading optional : number

Degrees clockwise from north to look toward. Absent, the heading now.

pitch optional : number

Degrees below the horizon to look down at the ground, from 0 to 90. Absent, the pitch now.

rangeScale optional : number

How many times as far from the ground to stand. Absent, as far as now.

viewport optional : string

Label of the viewports to turn. Absent, exactly one viewport must exist.

transactionId optional : string

setClearance

setClearance(args: { meters: number; viewport?: string }, transactionId?: string): Promise<void>

Set how near viewport cameras come to drawn geometry, in meters.

The clearance is the one distance a camera keeps from what it would hit: the ground under it, an object it zooms toward, and the ground under the flights geo.viewport.camera.fly_to start. A camera keeps it on every map it is put on, including maps opened later. A camera never given a clearance keeps 5 m. The setting belongs to the viewport, so it is not saved in the project and undo does not take it back.

Fails without changing anything unless meters is a finite number above zero and at most 100,000.

Returns Promise<void>.

meters : number

Meters the camera keeps from drawn geometry.

viewport optional : string

Label of the viewports to change. Absent, exactly one viewport must exist.

transactionId optional : string

setZoomOutLimit

setZoomOutLimit(args: { span: number; viewport?: string }, transactionId?: string): Promise<void>

Set how far viewport cameras zoom out from the globe, as the share of the view’s height the body’s disc spans where a zoom out stops.

The limit is a share of the view rather than a distance, so it stops a camera over each body at a distance in proportion to that body’s radius, and at the same size on the screen through any field of view. A camera keeps it on every map it is put on, including maps opened later. A camera never given a limit stops where the body’s map, pole to pole, fills the height of the view, about 0.64 of it. A flat map stops a zoom out at its own edges whatever this is set to. The setting belongs to the viewport, so it is not saved in the project and undo does not take it back.

Fails without changing anything unless span is a number from 0.00001 to 1.

Returns Promise<void>.

span : number

The share of the view’s height the body’s disc spans where a zoom out stops.

viewport optional : string

Label of the viewports to change. Absent, exactly one viewport must exist.

transactionId optional : string

zoomBy

zoomBy(args: { steps: number; viewport?: string }, transactionId?: string): Promise<void>

Zoom viewport cameras toward the middle of their view by a number of scroll wheel notches.

The zoom is the one a scroll wheel over the middle of the view makes, with the same limits, speed and easing, in the 2D view as in 3D, and over the sky as over the ground. Steps sent while an earlier zoom is still under way add to it.

Returns Promise<void>.

steps : number

How many notches to zoom: in for a positive count, out for a negative one. A fraction zooms that share of a notch.

viewport optional : string

Label of the viewports to zoom. Absent, exactly one viewport must exist.

transactionId optional : string

CameraDestination

type GeoViewportCameraCameraDestination = { kind: "cameraPose"; value: GeoViewportCameraCameraPose } | { kind: "lookAt"; value: GeoViewportCameraLookAt } | { kind: "cameraTarget"; value: GeoViewportCameraCameraTarget }

CameraPose

Camera placement in geographic coordinates.

cameraHeading : number

Degrees clockwise from north at the camera.

cameraPitch : number

Degrees below the camera’s local horizon: 0 horizontal, 90 down, and -90 up.

cameraPosition : GeoGeoPosition

The camera’s geographic position, not its target. Omitted elevation uses displayed ground.

CameraTarget

Position the camera and its target explicitly. Up follows the displayed map normal at the eye. Coincident positions fail. A vertical view uses the local east direction to fix roll.

cameraPosition : GeoGeoPosition

CameraView

Where a camera stands over the map.

cameraHeading : number

Degrees clockwise from north.

cameraPitch : number

Degrees below the horizon the camera looks down, so 90 looks straight down.

cameraPosition : GeoGeoPosition

center optional : GeoGeoPosition

The displayed ground under the viewport center, absent over sky or before presentation.

flatViewSpan optional : number

In the flat view, meters of ground the view’s height spans at the middle of the view, which follows the zoom where the height of cameraPosition does not. It depends on neither the window’s size nor a field of view, and LookAt.flat_view_span restores it. Absent in the 3D view and during a switch between the views.

map optional : SceneNode

The node geo.map.spawn_map answered for the map the camera stands on, absent while it stands on none.

FlightStage

Enum

How far a flight from one map’s body to another has come.

Canceled = 5

The flight ended before it reached the destination, such as when the map was deleted.

Climbing = 1

Climbing off the body the camera stood on.

Cruising = 2

Crossing open space toward the other body.

Departing = 0

Asked for, and not started yet.

Landed = 4

The camera has landed on the destination’s map.

Landing = 3

The camera stands on the destination’s map and descends to its landing.

FlightState

The last flight a camera was sent on with geo.viewport.camera.fly_to.

map : SceneNode

The map flown to.

LookAt

Frame a geographic target from a range in meters. A camera in the flat view lands straight over the target at the range with north up, whatever heading and pitch are asked for.

cameraHeading : number

Degrees clockwise from north at the target, measured in the direction the camera faces.

cameraPitch : number

Degrees below the target’s local horizon: 0 horizontal, 90 down, and -90 up.

cameraRange : number

Requested camera-to-target distance in ground meters. Flat projection scales scene distance. Unless exact is true, ground clearance can increase the distance or steepen the viewing angle.

exact optional : boolean

True lands the camera at exactly this range, heading and pitch, as when restoring a view that was read back, however near the drawn ground that puts it, short of its clearance over the ground under it. A camera that would stand lower is raised straight up to the clearance without turning. Absent means false.

flatViewSpan optional : number

Meters of ground the view’s height spans where a camera lands in the flat view, as getLocation reads flatViewSpan. It takes the place of cameraRange there, whatever the window’s size and the field of view. Absent, the flat view frames what a 3D camera at cameraRange shows. The 3D view ignores it.

target : GeoGeoPosition

The point the camera faces. Omitted elevation uses displayed ground.