The URL for loading has the format:
https://api-maps.yandex.ru/<version number>/?lang=<language id>&<additional parameters>
For commercial versions of the API, the download link has the format:
https://enterprise.api-maps.yandex.ru/<version number>/?lang=<language id>&apikey=<API key>&<additional parameters>
Version numbering is described in the section API versions.
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, maximum-scale=1" />
For more information, see the description of the "viewport" metatag in the Safari HTML Reference.
The API lets you display maps that are localized in various languages with allowances for the differences in specific countries. To control localization, pass the locale in the HTTP request.
The locale is set in the lang parameter:
The following locales are currently supported:
Note. In early versions of the API, the locale was specified after a dash. This notation is no longer recommended for use, but for backward compatibility, the locales ru-RU, tr-TR, en-US, and uk-UA are considered equivalent to ru_RU, tr_TR, en_US, and uk_UA.
API key. Used only in commercial versions of the API. You can get a key in the developer's dashboard.
Note. The key will be activated after the licensing agreement has been confirmed with Yandex.
The order for setting geographical coordinates in API functions that accept longitude-latitude input (for example, Placemark).
Default value: latlong.
List of modules to load.
Module names are comma-separated. For example, load=Map,Placemark,map.addon.balloon.
By default, all the API components are loaded (load=package.full), but in order to minimize the traffic sent to the client application, you can set a list of specific API entities that your application uses.
Note. package.full is optimized to load functionality at the time when it is actually used, so in most cases it is not necessary to configure the load parameter.
Components can also be loaded on demand, using the require function.
Default value: package.full.
API loading mode.
The API code can be loaded in packed format to minimize traffic and browser execution time (mode=release), or as source code (mode=debug).
Default value: release.
The namespace that the API programming components are localized in.
Using a namespace helps avoid crossovers between the names of functions and various programming components used in the API and in user code or other third-party code.
You can set an empty ns value. In this case, the API will not create objects in the global viewport, and access to API functionality will only be given to the function specified in the onload parameter.
Default value: ymaps.
Name of the function that must be called after the API components are loaded and ready to use (callback). The namespace object with API functionality will be passed to this function as an argument.
Nested namespaces may be used:
A usage example is provided in the table below.
The name of the callback function that will be called if an error occurs when loading the API. This function will be passed an object containing information about the error, in the form of an argument.
API components can also be enabled using the modules.require function, which is convenient when loading must depend on certain conditions.
Yandex.Map API components are always loaded asynchronously. This is true even if the script tag is used for enabling the API and no other special actions are performed for asynchronous loading.
|Using the ready() function||Using the onload loading parameter|
| || |
The occurrence of an event for loading the DOM tree or document does not indicate that the API has finished loading. In other words, using event handlers like document.ready, window.onload, jQuery.ready or others does not allow you to determine whether the components are ready for use.
For the map to be initialized, the DOM tree must contain the element that the map is placed in.
The ready function executes its code only after the API components and the document's DOM tree are loaded.
The function passed to the onload parameter is called after the API is loaded, but does not keep track of the DOM tree's readiness. In this case, you must track the availability of the HTML element that the map is placed in. For example, you can use the event handlers that are listed above.
Using the onload parameter lets you initialize the map without waiting for the DOM to be completely formed. This is why this method is the fastest way to load the API.