Searching for organizations

Open in CodeSandbox

The "Search on map" control can find toponyms on the normal or public map. But it is often necessary to find a business, instead of a specific toponym. For example, a cafe, restaurant, or store.

To teach the control to search for organizations, you must enable a specific data provider — "yandex#search". Let's look at examples of how to do this.

<!DOCTYPE html>
<html>
    <head>
        <title>Examples. Searching across your own objects</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/
    -->
        <script
            src="https://api-maps.yandex.ru/2.1/?lang=en_RU&amp;apikey=<your API-key>"
            type="text/javascript"
        ></script>
        <script src="search_control_ppo.js" type="text/javascript"></script>
        <style>
            html,
            body,
            #map {
                width: 100%;
                height: 100%;
                padding: 0;
                margin: 0;
            }
        </style>
    </head>
    <body>
        <div id="map"></div>
    </body>
</html>
function init() {
    var myMap = new ymaps.Map("map", {
        center: [55.74, 37.58],
        zoom: 13,
        controls: [],
    });

    /**
     * Creating an instance of the "Search on map" control
     * with the option enabled for the business search data provider.
     */
    var searchControl = new ymaps.control.SearchControl({
        options: {
            provider: "yandex#search",
        },
    });

    myMap.controls.add(searchControl);

    /**
     * Programmatically performing a search for specific cafes within the
     * rectangular map area.
     */
    searchControl.search("Shokoladnitsa");
}

ymaps.ready(init);