Documentation
Reference
2.1.56 (current version)
collection
interactivityModel
Interfaces

panorama.Player

Extends IEventEmitter.

Class for creating and controlling the panorama player.

Constructor | Fields | Events | Methods

Constructor

panorama.Player(element, panorama[, options])

Creates an instance of the panorama player.

Parameters:

ParameterDefault valueDescription
element *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: HTMLElement|String

A reference to the HTML element that will contain the player, or the ID of this HTML element.

panorama *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IPanorama

The panorama that will be opened in the created panorama player.

options

Type: Object

Options.

options.autoFitToViewport "always"

Type: String

The option to disable automatic tracking of the size of the player container. By default, the player always follows the size of its container, and reconstructs the image if the size has changed. Available values:

  • none — Do not track the size of the container.
  • ifNull — As soon as the container gets a CSS "display" value other than "None", the player automatically adjusts its size to the value. After that, tracking stops.
  • always — Always follow the size of the container.

options.controls

Type: String[]

Set of player controls. Available controls:

  • closeControl – The button that closes the player.
  • fullscreenControl – The button that switches the player to full screen mode.
  • panoramaName – The name of the panorama (automatically hidden in the small player).
  • zoomControl – Zoom control on the panorama.
The set of controls includes all of the above by default.

options.direction 'auto'

Type: Number[]|String

Direction of view in the format [bearing, pitch], where bearing – is the azimuth of the direction in degrees, and pitch is the angle of elevation above the horizon in degrees. The special string value auto means that the direction specified in the panorama's metadata is applied when opening the panorama.

options.hotkeysEnabled false

Type: Boolean

Enables keyboard control of the player. Please note that when you open the player, it begins to intercept some keys (e.g. arrow keys), thus canceling the default reaction of the browser, which may prevent the user from interacting with your page. This is why keyboard control is disabled by default.

options.scrollZoomBehavior true

Type: Boolean

Disables zooming of the panorama by scrolling. Enabled by default, and the player intercepts the mouse wheel events.

options.span 'auto'

Type: Number[]|String

The angular dimensions of the field of view in the format [horizontalSpan, verticalSpan], where horizontalSpan is the horizontal field size in degrees, and verticalSpan is the vertical field size in degrees.

options.suppressMapOpenBlock false

Type: Boolean

Whether to hide the offer to open the current panorama in Yandex.Maps with all the available map information preserved as completely as possible. true - hide, false - don't hide. The link to Yandex.Maps is displayed in the lower-left corner of the player.

* Mandatory parameter/option.

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

Events

NameDescription
destroy

The player was closed by the user or destroyed using the panorama.Player.destroy method.

directionchange

The view direction changed.

error

An error occurred during operation of the player. The user will be shown the appropriate screen.

fullscreenenter

The panorama player switched to full-screen mode.

fullscreenexit

The panorama player exited full-screen mode.

markercollapse

The user clicked on an expanded marker. Names of fields that are available via the Event#get method:

  • marker — The marker that was collapsed.

markerexpand

The user clicked on a collapsed marker. Names of fields that are available via the Event#get method:

  • marker — The marker that was expanded.

markermouseenter

The user's cursor hovered over a marker. Names of fields that are available via the Event#get method:

  • marker — The marker that the cursor hovered over.

markermouseleave

The user's cursor left a marker. Names of fields that are available via the Event#get method:

  • marker — The marker that the cursor moved away from.

panoramachange

The open panorama changed (for example, as the result of calling the panorama.Player.setPanorama function or a user action).

spanchange

The size of the viewport has been changed.

Methods

NameReturnsDescription
destroy()

Destroys the player.

fitToViewport()

Checks the size of the player container and if it has changed since the last inspection, rebuilds the image.

getDirection()

Number[]

Returns the current viewing direction, in the format [bearing, pitch], where bearing is the azimuth of the direction in degrees, and pitch is the angle of elevation above the horizon in degrees.

getPanorama()

IPanorama

Returns the panorama that is currently open in the player.

getSpan()

Number[]

Returns the current angular dimensions of the field of view, in the format [horizontalSpan, verticalSpan], where horizontalSpan is the horizontal field size in degrees, and verticalSpan is the vertical field size in degrees.

lookAt(point)

panorama.Player

Rotates the view so that the passed point is in the center of the field of view.

moveTo(point[, options])

vow.Promise

Searches for a panorama with the specified parameters and opens it.

setDirection(direction)

panorama.Player

Sets a new viewing direction.

setPanorama(panorama)

panorama.Player

Opens the passed panorama in the player.

setSpan(span)

panorama.Player

Sets new dimensions for the field of view.

Events details

destroy

The player was closed by the user or destroyed using the panorama.Player.destroy method.

directionchange

The view direction changed.

error

An error occurred during operation of the player. The user will be shown the appropriate screen.

fullscreenenter

The panorama player switched to full-screen mode.

fullscreenexit

The panorama player exited full-screen mode.

markercollapse

The user clicked on an expanded marker. Names of fields that are available via the Event#get method:

  • marker — The marker that was collapsed.

markerexpand

The user clicked on a collapsed marker. Names of fields that are available via the Event#get method:

  • marker — The marker that was expanded.

markermouseenter

The user's cursor hovered over a marker. Names of fields that are available via the Event#get method:

  • marker — The marker that the cursor hovered over.

markermouseleave

The user's cursor left a marker. Names of fields that are available via the Event#get method:

  • marker — The marker that the cursor moved away from.

panoramachange

The open panorama changed (for example, as the result of calling the panorama.Player.setPanorama function or a user action).

spanchange

The size of the viewport has been changed.

Methods details

destroy

{} destroy()

Destroys the player.

fitToViewport

{} fitToViewport()

Checks the size of the player container and if it has changed since the last inspection, rebuilds the image.

getDirection

{Number[]} getDirection()

Returns the current viewing direction, in the format [bearing, pitch], where bearing is the azimuth of the direction in degrees, and pitch is the angle of elevation above the horizon in degrees.

getPanorama

{IPanorama} getPanorama()

Returns the panorama that is currently open in the player.

getSpan

{Number[]} getSpan()

Returns the current angular dimensions of the field of view, in the format [horizontalSpan, verticalSpan], where horizontalSpan is the horizontal field size in degrees, and verticalSpan is the vertical field size in degrees.

lookAt

Rotates the view so that the passed point is in the center of the field of view.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
point*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[]

The point to rotate the view at. It can be an array of two or three coordinates. The first two coordinates are interpreted as the geographical coordinates of the point. If three coordinates are passed, the third is interpreted as the height of the point relative to the panorama in meters.

* Mandatory parameter/option.

moveTo

Searches for a panorama with the specified parameters and opens it.

Returns a promise object that will be resolved if the panorama is found and successfully opened in the player, or rejected with an error message otherwise.

Parameters:

ParameterDefault valueDescription
point*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[]

The point for searching for nearby panoramas.

options

Type: Object

Options.

options.direction 'auto'

Type: Number[]|String

Direction of view in the format [bearing, pitch], where bearing is the azimuth of the direction in degrees, and pitch is the angle of elevation above the horizon in degrees. The special string value auto means that the direction specified in the panorama's metadata is applied when opening the panorama.

options.layer 'yandex#panorama'

Type: String

The layer to search for panoramas. There are two layers available:

  • yandex#panorama - Land panoramas.
  • yandex#airPanorama - Aerial panoramas.

options.span 'auto'

Type: Number[]|String

The angular dimensions of the field of view in the format [horizontalSpan, verticalSpan], where horizontalSpan is the horizontal field size, and verticalSpan is the vertical field size.

* Mandatory parameter/option.

setDirection

{panorama.Player} setDirection(direction)

Sets a new viewing direction.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
direction*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[]|String

Direction of view in the format [bearing, pitch], where bearing is the azimuth of the direction in degrees, and pitch is the angle of elevation above the horizon in degrees. The special string value auto means that the direction specified in the panorama's metadata is applied when opening the panorama.

* Mandatory parameter/option.

setPanorama

{panorama.Player} setPanorama(panorama)

Opens the passed panorama in the player.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
panorama*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IPanorama

Panorama.

* Mandatory parameter/option.

setSpan

Sets new dimensions for the field of view.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
span*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[]|String

The angular dimensions of the field of view in the format [horizontalSpan, verticalSpan], where horizontalSpan is the horizontal field size in degrees, and verticalSpan is the vertical field size in degrees.

* Mandatory parameter/option.