Controlling the panorama display

When a panorama is displayed in the panorama player, standard UI controls are automatically added to it. They allow users to change the viewing angle on the panorama and enable full-screen mode. These controls are added both to Yandex panoramas and to custom panoramas. The developer can explicitly define which controls to add to the panorama.

Note. The API does not allow you to change the appearance of the panorama controls.

In addition, the API has a set of functions that you can use to control the panorama image at the code level. The panorama player generates various events that you can set or remove callback functions for.

Controls

By default, the following controls are added to the panorama:

Note. The “Open in Yandex.Maps” link is only displayed on Yandex panoramas. This control can't be hidden.

To define the set of controls that will be added to the panorama, use the 'controls' option when creating an instance of the player (panorama.Player):

var player = new ymaps.panorama.Player('div_id', panorama, {
// Only the panorama name and the “Open in Yandex.Maps” link will be shown on the panorama.
controls: ['panoramaName']
});

Note that the API does not allow you to change the appearance of the panorama controls.

Controlling the panorama image programmatically

The panorama player provides various functions for controlling the panorama image. For example, you can change the viewing direction, connect to another panorama, and so on. Methods for working with the panorama are listed below.

setDirection

Sets a new viewing direction on the panorama. Set 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. For more information, see the Reference.

player.setDirection([10, 10]);

setSpan

Sets the size of the field of view on the panorama. For more information, see the Reference.

player.setSpan([10, 10]);

lookAt

Sets the viewing direction so that the passed point is in the center of the field of view.

player.lookAt([69.92620155262, 31.3111500947]);

moveTo

Searches for a panorama with the specified parameters and switches to it.

Note. To go to the aerial panorama, specify the layer option with the value 'yandex#airPanorama' (you need to specify this option even if the current panorama that you are leaving is also an aerial panorama).

To get information about the status of displaying the panorama, you can use the following methods:

getPanorama

Returns the panorama that is currently open in the panorama player. For more information, see the Reference.

var panorama = player.getPanorama();
// Now we can get some information about the panorama itself, such as its name.
// For more information, see Getting information about a panorama.
console.log("Panorama name: " + panorama.getName());

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. For more information, see the Reference.

Use the remove() function to cancel a subscription to an event. Pass the event type as the first argument of the function, and a reference to the callback function to delete (but not the callback itself) as the second argument. For example: