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

# Positioning the map to display geocoding results and clustering

<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/apply_bounds_and_clusterize/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/ncyry7?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/GeoObject">GeoObject</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>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geocode">geocode</a>
</div>
<p>
    This example demonstrates how to add geocoding results to the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult">GeoQueryResult</a> selection.
    Using the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult#applyBoundsToMap">applyBoundsToMap</a> method, set the mapping area
    so that all the objects in the selection fall within it.
    Use the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult#clusterize">clusterize</a> method to add the objects to the clusterer.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>

    <html>
        <head>
            <title>
                Examples. Positioning the map to display geocoding results and
                clustering
            </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>Clustered results for the request "Arbat" are shown</p>
            <div id="map"></div>
        </body>
    </html>
    ```

-   apply_bounds_and_clusterize.js

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

        /**
         * Making a geocoding request, then positioning the map so that
         * all objects fall within the map viewport
         * and the zoom level is as high as possible.
         */
        var result = ymaps
            .geoQuery(ymaps.geocode("Arbat"))
            .applyBoundsToMap(myMap, { checkZoomRange: true });
        /**
         * Clustering the resulting objects and adding the clusterer to the map.
         * Note that the clusterer is created immediately, but the objects are added to it
         * only after the response is received from the server.
         */
        myMap.geoObjects.add(result.clusterize());
    }
    ymaps.ready(init);
    ```

{% endlist %}
