The advanced, manual camera controls for MapView. You probably don't need to use this at all, instead relying on the MapView's focusOn, resetCamera and built in touch/mouse controls. This class will let you do things like change the min/max zoom, tilt, and pan, attach to camera events, and move/animate the camera to specifc points.

The camera works by setting an anchor point on the scene at ground level and pointing the camera at it. zoom controls how far the camera is from the anchor, and tilt/rotate controls the angle the camera is rotated about it. The camera will always be pointed directly at the anchor point. pan or setPosition will move that anchor around on the 2D ground plane.

Created for you automatically with a MapView, don't re-create yourself.

Show:
animateCamera
(
  • target
  • duration
  • curve
  • callback
  • options
)
Mappedin.Tween

Animates the camera from it's current position to the state specified in target. You only need to specify the properties you actually want to change.

You can also specify a duration, animation curve, and a callback for when it's done.

Parameters:

  • target Object

    A list of optional parameters you can set that represent the camera state.

    • [position] Object optional

      An {x, y, z} object representing the position to move to.

    • [zoom] Number optional

      The zoom level to end at.

    • [tilt] Number optional

      The tilt to end at, in radians.

    • [rotation] Number optional

      The rotation to end at, in radians.

    • [doNotAutoStart=false] Boolean optional

      Set this to true if you want to start the tween yourself.

  • [duration] Number optional

    The duration to animate the camera for, in ms.

  • [curve] Mappedin.Easing optional

    The animation curve to use for the animation.

  • [callback] Function optional

    A callback that will be executed when the animation is done.

  • [options] Object optional

    An Options object

    • [mode=cancel] Object optional

      Mode determines what happens when multiple animateCamera calls happen at once. By Default, it will cancel and omit any previous animations. Set to "chain" to chain instead

Returns:

Mappedin.Tween:

The tween being used, if you want to do anything to control it manually. Do not overide it's events.

dispose () private

Disposes of the camera and all of it's events.

expandZoomLimits
(
  • zoom
  • buffer
)

Expands the zoom limits to allow zooming to the specified distance.

Parameters:

  • zoom Number

    The distance to allow zooming to.

  • buffer Number

    The factor by which the user should be able to zoom beyond the specified distance.

getPosition () Object

Returns the current camera position.

Returns:

Object:

An {x, y} object of the current camera postion.

getRotation () Number

Returns the current camera rotation.

Returns:

Number:

The current rotation of the camera, in radians.

getTilt () Number

Returns the current camera tilt

Returns:

Number:

The current tilt of the camera, in radians.

getZoom () Number

Returns the current camera zoom

Returns:

Number:

The distance of the camera from the anchor.

getZoomScaledMax () Number

Returns the actual zoom maximum based on visible map size.

Returns:

Number:

The actual zoom maximum in map units.

getZoomScaledMin () Number

Returns the actual zoom minimum based on real-world distance.

Returns:

Number:

The actual zoom minimum in map units.

isCameraMoving () Boolean

Returns true if the camera is currently moving (it's animating, the user is manipulating it).

Returns:

Boolean:

True if the camera is moving, false otherwise.

pan
(
  • right
  • down
)

Pans the camera right and down from the current position

Parameters:

  • right Number

    The units to move right. Negative will pan left. This is in relation to the global coordinate system, not the current camera rotation.

  • down Number

    The units to move down. Negative will pan up. This is in relation to the global coordinate system, not the current camera rotation.

postRender () private

Anything we need to do after we render the camera, like update anchors for the mouse/touch controls.

restrictZoomLimits
(
  • zoom
  • buffer
)

Restricts the zoom limits, but will not restrict beyond the current zoom level.

Parameters:

  • zoom Number

    The number to limit zooming to.

  • buffer Number

    The factor by which the user should be able to zoom beyond the specified distance.

rotate
(
  • radians
)

Rotates the camera a set number of radians relative to the current rotation. Useful for an idle rotation animation.

Parameters:

  • radians Number

    Number of radians to rotate the camera.

setMulti
(
  • position
  • zoom
  • rotation
  • tilt
)

Allows you to set any of the Camera's position, zoom, rotation and tilt at once, with one function.

Parameters:

  • [position] Object optional

    an {x, y, z} object representing the new position.

  • [zoom] Number optional

    The new zoom distance.

  • [rotation] Number optional

    The new rotation, in radians.

  • [tilt] Number optional

    The new tilt, in radians.

setPosition
(
  • x
  • y
)

Sets the camera anchor to a specifc x/y positon, in the global reference frame. 0,0 will be roughly the middle of the map, and panBounds holds the min/max points.

Parameters:

  • x Number

    The x position to move the camera to. +x will take you right, from the default camera rotation of 0.

  • y Number

    The y position to move the camera to. +y will take you down (towards the viewer) in the default camera rotation of 0.

setRotation
(
  • radians
)

Sets the rotation to a specific orientation, in radians. Mostly useful to orient the map a certain way for a physical directory.

Parameters:

  • radians Number

    Absolute rotation to set the camera to, in radians. 0 in the starting point.

setTilt
(
  • radians
)

Sets the tilt to a specific level, in radians. 0 is top down. Bounded by minTilt and maxTilt.

Parameters:

  • radians Number

    Tilt to set the camera to, in radians.

setZoom
(
  • zoom
)

Sets the camera to be a certain distance from the anchor point, along it's tilt and rotation. Keeps it inside minZoom and maxZoom.

Parameters:

  • zoom Number

    The distance to set the camera to.

tilt
(
  • radians
)

Tilts the camera up or down by some number of radians. Bounded by minTilt and maxTilt.

Parameters:

  • radians Number

    Number of radians to increase or decrease the current tilt by.

update () private

Should probably be "pre-render". Anything we need to do before rendering the scene.

zoom
(
  • zoom
)

Moves the camera towards or away from the camera by a set amount. Positive will zoom in (bringing the distance closer to 0).

Parameters:

  • zoom Number

    The distance to increase or decrease the zoom.

zoomIn
(
  • duration
  • curve
  • callback
)

Zooms the camera in on the center of the current view.

Parameters:

zoomOut
(
  • duration
  • curve
  • callback
)

Zooms the camera out from the center of the current view.

Parameters:

CAMERA_EVENTS

Object const

Camera events you can attach a listener to (with controls.addListener(event, function)), if you want to do certain things. They'll be fired both by touch events and by functions you can call yourself like pan() and tilt()/

Sub-properties:

  • CHANGE_EVENT Object

    Fired whenever the camera changes.

  • PAN_START_EVENT Object

    Fired when the camera starts panning.

  • PAN_END_EVENT Object

    Fired when the camera finishes panning.

  • ROTATE_START_EVENT Object

    Fired when the camera starts rotating.

  • ROTATE_END_EVENT Object

    Fired when the camera stops rotating.

  • ZOOM_START_EVENT Object

    Fired when the camera starts zooming.

  • ZOOM_END_EVENT Object

    Fired when the camera finishes zooming.

  • MULTI_START_EVENT Object

    Fired when the camera starts animating or you called setMulti. It means any one or more of pan, tilt, rotate and zoom could be changing. The individual pan/tilt/rotate/zoom events will NOT be fired.

  • MULTI_END_EVNT Object

    Fired when the camera stops animating, or has finished the setMulti call.

enabled

Boolean

Disable or re-enable user input.


Default: true

enablePan

Boolean

Disable or re-enable user pan.


Default: true

enablePedestal

Boolean

Disable or re-enable user pedestal.


Default: false

enableRotate

Boolean

Disable or re-enable user tilt/rotation.


Default: true

enableZoom

Boolean

Disable or re-enable user zoom.


Default: true

initialMaxZoom

Number

Initial max zoom; zoom cannot be restricted beyond this.


Default: 10000

initialMinZoom

Number

Initial min zoom; zoom cannot be restricted beyond this.


Default: 375

maxPedestal

Number

Max amount to allow scrolling maps down (In Z-axis units, at the origin, down is positive)


Default: Infinity

maxTilt

Number

Minium camera tilt, in radians. If you set it too high, the camera will be able to tilt down through the geometery of the scene, which will produce clipping issues.


Default: 1.2

maxZoom

Number

Maximum distance the camera can get from it's anchor on the ground. Setting this too high will result in parts of the map falling out of the camera's clipping plane and disappearing.


Default: 10000

minPedestal

Number

Max amount to allow scrolling maps up (In Z-axis units, at the origin, up is negative)


Default: -Infinity

minTilt

Number

Minium camera tilt, in radians. If it's anything other than 0, you won't be able to look at the venue from the top down perspective.


Default: 0.0

minZoom

Number

This is actually the minium distance the camera can get from it's anchor on the ground. May be worth changing if your map has very tall buildings to avoid the camera clipping through them.


Default: 375

mouseButtons

Object

If you would really prefer to pan with the right mouse button and tilt/rotate with the left, you can swap the values here to achieve that.

Sub-properties:

  • ORBIT=MOUSE.RIGHT MOUSE

    The button to use for tilt/rotation. Defaults to MOUSE.RIGHT.

  • ZOOM=MOUSE.MIDDLE MOUSE

    The button to use for zoom behaviour. Don't change this.

  • PAN=MOUSE.LEFT MOUSE

    The button to use for panning the camera. Defaults to MOUSE.LEFT.

panBounds

Object

Constrains the camera from panning to far away from the scene. It's set automatically based on the size of the map. If you want to change anything, you probably want to change the margin property, which is the factor the min and max in each dimension are multiplied by to give the true bounds. For example, on a truely huge venue a 1.25 margin could get you way out into space when zoomed in.

Sub-properties:

  • margin Number

    The factor the multiply the size of the geometery by to give the true camera bounds.

  • min Object

    An x, y pair representing the bounds of one corner of the map.

  • max Object

    An x, y pair representing the bounds of the other corner of the map.

rotateSpeed

Float

Factor to multiple mouse movement by to get tilt/rotation.


Default: 100

zoomFactor

Number

Multiplier for min and max zoom, for convenience.


Default: 1

zoomSpeed

Float

Factor that controls how fast zooming in and out happens in response to mouse wheel events


Default: 5.0