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

# Adding objects to the visible area of the map

<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/show_visible_objects/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/cmm9mc?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/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map">Map</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Placemark">Placemark</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geoQuery">geoQuery</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult">GeoQueryResult</a>
</div>
<p>
    Use the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult">GeoQueryResult</a> method to create objects on the map from their JSON descriptions.
</p>
<p>
    This example explains how to add only objects that fall in the visible area to the map.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>

    <html>
        <head>
            <title>
                Examples. Displaying objects in the visible area of the map.
            </title>
            <meta
                http-equiv="Content-Type"
                content="text/html; 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>
            <p>
                Only placemarks that fall in the visible area are added to the
                map
            </p>
            <div id="map"></div>
        </body>
    </html>
    ```

-   show_visible_objects.js

    ```js
    ymaps.ready(init);

    function init() {
        var myMap = new ymaps.Map(
            "map",
            {
                center: [55.73, 37.75],
                zoom: 8,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        // Creating objects based on JSON descriptions of geometries.
        var objects = ymaps.geoQuery([
            {
                type: "Point",
                coordinates: [55.73, 37.75],
            },
            {
                type: "Point",
                coordinates: [55.1, 37.45],
            },
            {
                type: "Point",
                coordinates: [55.25, 37.35],
            },
            {
                type: "Point",
                coordinates: [55.25, 67.35],
            },
        ]);

        // Finding objects in the visible area of the map.
        objects
            .searchInside(myMap)
            // And then adding the found objects to the map.
            .addToMap(myMap);

        myMap.events.add("boundschange", function () {
            // After each shift of the map we will see what objects are in the visible area.
            var visibleObjects = objects.searchInside(myMap).addToMap(myMap);
            // Then we'll delete the other objects from the map.
            objects.remove(visibleObjects).removeFromMap(myMap);
        });
    }
    ```

{% endlist %}
