Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Viewer

class

Viewer

classdesc

The Viewer object represents the navigable photo viewer. Create a Viewer by specifying a container, client ID, photo key and other options. The viewer exposes methods and events for programmatic interaction.

Hierarchy

  • EventEmitter
    • Viewer

Index

Constructors

constructor

  • Create a new viewer instance.

    Parameters

    • id: string

      required id of an DOM element which will be transformed into the viewer.

    • clientId: string

      required Mapillary API ClientID, can be obtained from https://www.mapillary.com/app/settings/developers.

    • Optional key: string

      optional photoId to start from, can be any Mapillary photo, if null no image is loaded.

    • Optional options: IViewerOptions

      optional configuration object specifing Viewer's initial setup.

    Returns Viewer

Events

on

  • on(eventType: string, fn: any): void
  • Subscribe to an event by its name

    Parameters

    • eventType: string
    • fn: any

    Returns void

Static loadingchanged

loadingchanged: string = "loadingchanged"

Fired when the viewer is loading more data.

type

{boolean} loading - Value indicating whether the viewer is loading.

Static movestart

movestart: string = "movestart"

Fired when the viewer starts transitioning from one view to another, either by changing the node or by interaction such as pan and zoom.

Static nodechanged

nodechanged: string = "nodechanged"

Fired every time the viewer navigates to a new node.

type

{Node} node - Current node.

Properties

Private _componentController

_componentController: ComponentController

Private ComponentController object which manages component states.

Private _container

_container: Container

Private Container object which maintains the DOM Element, renderers and relevant services.

Private _eventLauncher

_eventLauncher: EventLauncher

Private EventLauncher object which fires events on behalf of the viewer.

Private _navigator

_navigator: Navigator

Private Navigator object which controls navigation throught the vast seas of Mapillary.

Static moveend

moveend: string = "moveend"

Fired when the viewer finishes transitioning and is in a fixed position with a fixed point of view.

Methods

activateComponent

  • activateComponent(name: string): void
  • Activate a component.

    Parameters

    • name: string

      Name of the component which will become active.

    Returns void

activateCover

  • activateCover(): void
  • Activate the cover (deactivates all other components).

    Returns void

auth

  • auth(token: string, projectKey?: string): void
  • Set an OAuth 2.0 bearer token for API requests of protected resources.

    description

    When the supplied access token is an empty string or null, any previously set access token will be cleared.

    Parameters

    • token: string

      OAuth 2.0 bearer token.

    • Optional projectKey: string

      Deprecated.

    Returns void

deactivateComponent

  • deactivateComponent(name: string): void
  • Deactivate a component.

    Parameters

    • name: string

      Name of component which become inactive.

    Returns void

deactivateCover

  • deactivateCover(): void
  • Deactivate the cover (activates all components marked as active).

    Returns void

fire

  • fire(eventType: string, data: any): void
  • Parameters

    • eventType: string
    • data: any

    Returns void

getCenter

  • getCenter(): when.Promise
  • Get the basic coordinates of the current photo that is at the center of the viewport.

    description

    Basic coordinates are on the [0, 1] interval and has the origin point, [0, 0], at the top left corner and the maximum value, [1, 1], at the bottom right corner of the original photo.

    Returns when.Promise

    Promise to the basic coordinates of the current photo at the center for the viewport.

getComponent

  • getComponent<TComponent>(name: string): TComponent
  • Get a component.

    Type parameters

    • TComponent: Component<IComponentConfiguration>

    Parameters

    • name: string

      Name of component.

    Returns TComponent

    The requested component.

getZoom

  • getZoom(): when.Promise
  • Get the photo's current zoom level.

    Returns when.Promise

    Promise to the viewers's current zoom level.

moveCloseTo

  • moveCloseTo(lat: number, lon: number): when.Promise
  • Move close to given latitude and longitude.

    Parameters

    • lat: number

      Latitude, in degrees.

    • lon: number

      Longitude, in degrees.

    Returns when.Promise

    Promise to the node that was navigated to.

moveDir

  • Navigate in a given direction.

    description

    This method has to be called through EdgeDirection enumeration as in the example.

    example

    viewer.moveDir(Mapillary.EdgeDirection.Next);

    Parameters

    Returns when.Promise

    Promise to the node that was navigated to.

moveToKey

  • moveToKey(key: string): when.Promise
  • Navigate to a given photo key.

    throws

    {ParamaterMapillaryError} If no key is provided.

    Parameters

    • key: string

      A valid Mapillary photo key.

    Returns when.Promise

    Promise to the node that was navigated to.

off

  • off(eventType: string, fn: any): void

resize

  • resize(): void
  • Detect the viewer's new width and height and resize it.

    description

    The components will also detect the viewer's new size and resize their rendered elements if needed.

    Returns void

setCenter

  • setCenter(center: number[]): void
  • Set the basic coordinates of the current photo to be in the center of the viewport.

    description

    Basic coordinates are on the [0, 1] interval and has the origin point, [0, 0], at the top left corner and the maximum value, [1, 1], at the bottom right corner of the original photo.

    Parameters

    • center: number[]

    Returns void

setRenderMode

  • Set the viewer's render mode.

    example

    viewer.setRenderMode(Mapillary.RenderMode.Letterbox);

    Parameters

    Returns void

setZoom

  • setZoom(zoom: number): void
  • Set the photo's current zoom level.

    description

    Possible zoom level values are on the [0, 3] interval. Zero means zooming out to fit the photo to the view whereas three shows the highest level of detail.

    Parameters

    • zoom: number

    Returns void

Generated using TypeDoc