2.1.38 (current version)

Hotspot layer

Hotspot technology is a way to load and display a large quantity of objects while achieving high performance.

When using hotspots, instead of showing thousands of separate objects, a single layer is displayed that contains images of all these objects. On top of the layer with object images, there is another layer with information about these objects and their borders. This layer allows the objects to be interactive, meaning that we can program an object's reaction to user actions.

The advantage of this method is that information is downloaded from the server only for the objects that are located on the tile that the mouse cursor is on. In addition, data caching can be used.

Hotspot layers are used, for example, when displaying traffic on Yandex maps.

Hotspot technology

The layer containing images of objects is called the image layer and, like any other layer, it is made up of tiles. To create this layer, you need to generate an image of the tiles where objects will be displayed on the map. The tile background must be transparent.

In order for the objects to be interactive, meaning that users can interact with them, the hotspot layer is added to the map on top of the image layer. It provides the API with information about which parts of the map should be interactive.

An interactive section of the map is called a hotspot and is represented by one or several simple geometric shapes. The hotspot is an abstract concept – you can't see it on the map.

The hotspot layer contains information about hotspots: their position, geometry types, and certain properties (for example, the contents of their balloons or hints). This information is provided in JSON format.

To store the hotspot layer data, the same tile technologies are used as for normal map layers. This means that data is arranged in 256x256 pixel squares that are divided for all the zoom levels. Hotspot data is stored on the server.

The hotspot layer exchanges data with the server using a special object, the data source. The data source generates and sends a request for information about hotspots on the necessary tile and returns the data to the layer.

The layer stores the hotspot data only for the tile that the mouse cursor is on. When the user moves the mouse cursor to a different tile, the layer requests data for the new tile from the server. As soon as the server returns the response, the layer deletes the previous layer's data. So the layer does not store data that was downloaded earlier.

However, it is possible to use the browser cache. For more details, see the section Using the browser cache.

The hotspot layer and the image layer exist independently of each other, and it does not matter in which order they are added to the map. In some cases, the hotspot layer can be used without the image layer (for example, to make an interactive image of some building on the map). The map may have multiple hotspot layers added to it.