Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.51 (release candidate)
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, reconstructing the image, if it has changed. Available values:

  • none — do not follow the size of the container.
  • ifNull — as soon as the container will get a CSS value "display", which is not "None", the player will automatically adjusts its size to the value. After that the status following will be stopped.
  • 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 in full screen mode,
  • panoramaName – the name of the panorama (automatically hidden in the player of a small size),
  • zoomControl – zoom control of 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, pitch – angle of elevation above the horizon in degrees. A special string value auto means that after opening of the panorama, the direction specified in the panorama's metadata will be applied.

options.hotkeysEnabled false

Type: Boolean

Enables to control the player using the keyboard. 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 hinder the user to interact with your page. So the keyboard control is switched off 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 – the horizontal field size in degrees, verticalSpan – 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.

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 which 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.

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 which 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, pitch – angle of elevation above the horizon in degrees. A special string value auto means that after opening of the panorama, the direction specified in the panorama's metadata will be applied.

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 – the horizontal field size, verticalSpan – 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, pitch – angle of elevation above the horizon in degrees. A special string value auto means that after opening of the panorama, the direction specified in the panorama's metadata will be applied.

* 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.