---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/examples/cases/panorama_basics.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/panorama_basics.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# Inserting into the Yandex panoramas page

<iframe id="LIVE-EXAMPLE" style="width:100%;height: 400px;border-radius: 8px;border: 1px solid rgba(92, 94, 102, 0.14);" frameBorder="0" src="https://yastatic.net/s3/front-maps-static/maps-front-jsapi-v2-1/examples/2/out/s3-cases/en/panorama_basics/index.html" allow="fullscreen"></iframe>

<a target="_blank" rel="noopener noreferrer" style="display: inline-block;margin-top: 10px;cursor: pointer;border-radius: 4px;padding: 9px 12px;background: #151515;color: white;text-decoration: none;font-weight: 500" href="https://codesandbox.io/p/sandbox/ntycnx?file=index.html">Open in CodeSandbox</a>

<div id="references">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.isSupported">panorama.isSupported</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.locate">panorama.locate</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.createPlayer">panorama.createPlayer</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.Player">panorama.Player</a>
</div>
<p>
    The Yandex.Maps API allows you to display Yandex panoramas on website pages.
</p>
 <p>
     The panorama is implemented by <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Panorama">Panorama</a>. This object contains the necessary information
     about the panorama: its name, geographical coordinates,connections to linked panoramas, and so on.
 </p>
<p>
     The <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.Player">panorama.Player</a> object (the player) is used for adding a panorama 
     to a page. The player forms requests for tiles and creates the &lt;canvas> element on the page for displaying the panorama. To insert a panorama on the page, just pass the player constructor the panorama object (Panorama). </p>
<p>
    You can use the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.locate">panorama.locate</a> function to get the panorama object. As input it is passed the geographical coordinates
    of the point to get a panorama for. The function returns an array of panoramas found in the vicinity of this point.
    The panoramas in the array are sorted by distance from the point.
</p>
<p>
    You can also use the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/panorama.createPlayer">panorama.createPlayer</a> function for adding panoramas to a web page. For input, it takes
    the coordinates of the point where a panorama should be opened. The function searches for the nearest panorama and, if successful, it
    creates a panorama player with the found panorama.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <title>Examples. Getting Yandex panoramas.</title>
            <meta charset="UTF-8" />

            
            <!--
            Set your own API-key. Testing key is not valid for other web-sites and services.
            Get your API-key on the Developer Dashboard: https://developer.tech.yandex.ru/keys/
        -->
            
            
        </head>
        <body>
            <div id="player1" class="player"></div>
            <div id="player2" class="player"></div>
        </body>
    </html>
    ```

-   panorama_basics.js

    ```js
    ymaps.ready(function () {
        // To begin with, we have to check whether the user's browser supports the panorama player.
        if (!ymaps.panorama.isSupported()) {
            // If it doesn't, we won't do anything.
            return;
        }

        // Searching for a panorama at the point passed.
        ymaps.panorama.locate([55.733685, 37.588264]).done(
            function (panoramas) {
                // Checking that at least one panorama was found.
                if (panoramas.length > 0) {
                    // Creating the panorama player with one of the panoramas found.
                    var player = new ymaps.panorama.Player(
                        "player1",
                        /**
                         * The panoramas in the response are sorted by their distance
                         * from the point passed in 'panorama.locate'.
                         * We are choosing the first one because it will be the closest.
                         */
                        panoramas[0],
                        /**
                         * Setting a viewing direction different
                         * from the default value.
                         */
                        { direction: [256, 16] }
                    );
                }
            },
            function (error) {
                // If something went wrong, we notify the user.
                alert(error.message);
            }
        );

        /**
         * You can also use the 'panorama.createPlayer' method
         * for adding panoramas to a page. This method searches for the nearest panorama
         * and if successful, it creates a panorama player with the found panorama.
         */
        ymaps.panorama
            .createPlayer(
                "player2",
                [59.938557, 30.316198],
                // Searching for an aerial panorama.
                { layer: "yandex#airPanorama" }
            )
            .done(function (player) {
                // player – a link to the player instance.
            });
    });
    ```

{% endlist %}
