FAQ

How can I use a specific version of the JavaScript API?

To do this, specify the version number in the connection link. For example:

<script src="https://api-maps.yandex.ru/2.1.40/?apikey=<API key>&lang=en_US" type="text/javascript">
</script>

Note

We may eventually deprecate an outdated minor version of the JavaScript API. If you were using this version in your project, you will be automatically switched to the newest version of the API.

How can I insert a map in a blog if it doesn't allow scripts?

If your blog hosting service does not allow the use of scripts, you won't be able to embed an interactive map via the JavaScript API. However, you can use the Map Widget to embed an interactive map. When you add the Map Widget to the website, the map is placed in a separate iframe.

You can also use a static map image. To get the map image, use the Map Constructor or the Static API.

Can I use the Yandex Maps API on a website with CSP?

Yes, you can. For more information, read Enabling the API when using CSP in the documentation.

I am using the JavaScript API to show a map on my website, but the map doesn't display. What am I doing wrong?

  1. Make sure you pass the correct key when enabling the API. If you don't have a key, get one in the Developer's Dashboard.
  2. Make sure you specified the correct ID of the DOM element when creating the map instance.
  3. Check whether the size is set for the map container (it can't have a zero size).
  4. The map isn't displayed if the API code wasn't loaded yet when the map was created. To guarantee that the API code is loaded when working with the map, we recommend putting it in the ymaps.ready() function. For more information, see Enabling the API.

Can I store the map state in the URL?

Yes, you can. See the example.

How can I add my own map layer to the map?

See the example.

Why did geolocation stop working (or can't show an accurate location) on my website?

Most likely, your service is located in an HTTP domain. Google has prohibited using the browser to detect location on non-HTTPS domains. In this case, the browser console outputs this information: https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins

When I set properties or options for map objects, they aren't applied. What could be the reason for this problem?

It's possible that you are not using the prefixes correctly when setting properties or options. For example, to set properties for a placemark icon, you need to use the 'icon' prefix (iconLayout). But to set properties for a cluster icon, you need to use the 'clusterIcon' prefix (clusterIconLayout). In addition, the correct use of prefixes depends on the level of the property, i.e., whether you are setting it for the object itself, for its collection, or on the map level. For more information, see Using prefixes in option names.

Can I change the appearance of route points?

Yes, you can. Example in the sandbox: Configuring the view of a multiroute.

Why aren't placemarks shown on the map when clustering is used?

You might be adding both a cluster and separate placemarks in this cluster at the same time. You should only add the cluster. For more information, see Clusters.

I want to calculate the area of a polygon/rectangle/circle on the geodesic surface. Is there a special tool for this in the API?

You can use an external module to calculate the geodesic area of shapes: https://github.com/yandex/mapsapi-area. You can use this module along with the API.

The Geocoder returns an empty response or the wrong type of result. What should I do?

  1. If you are using reverse geocoding, make sure the coordinates are listed in the correct order in your request. By default, the Geocoder accepts coordinates in «longitude, latitude» order. You can change the coordinate order in the sco parameter.
  2. Make sure you specified the correct borders for the search area (the bbox or ll+spn parameters). The object you are searching for might be located outside of the set search area.
  3. If the object you are searching for doesn't exist on the Yandex map, you can add it by drawing it in the Map Editor or report an error on the Yandex Maps page.

Support

If you haven't found the answer to your question, you can ask us.