ObjectManager

The ObjectManager object manager is an easy-to-use tool for managing large numbers of objects on the map. It allows adding more than a thousand objects to the map, managing their visibility, and clustering them if necessary, while providing acceptable performance.

Note

ObjectManager doesn't allow dragging objects (it doesn't support the draggable option). Objects are displayed only in the central world and do not jump over when the map is dredged.

It also doesn't support object editing.

ObjectManager is a layer containing a description of objects in JSON format. The description must contain object IDs, information about their geometries, and coordinates. It can also specify additional information about the objects being added, such as their balloon contents.

To use ObjectManager, the JSON description of objects must first be downloaded from the server (for example, using the Query.getJSON() function).

To put objects on the map, pass the manager the JSON description of these objects and add the manager to the map.

Example of a JSON description of objects
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 0,
      "geometry": {
        "type": "Point",
        "coordinates": [55.831903, 37.411961]
      },
      "properties": {
        "balloonContent": "Balloon content",
        "clusterCaption": "Placemark 1",
        "hintContent": "Hint text"
      }
    },
    {
      "type": "Feature",
      "id": 1,
      "geometry": {
        "type": "Point",
        "coordinates": [55.763338, 37.565466]
      },
      "properties": {
        "balloonContent": "Balloon content",
        "clusterCaption": "Placemark 2",
        "hintContent": "Hint text"
      }
    }
  ]
}

The ID uniquely identifies each object of the manager. You can use the ID to get access to the desired object and, for example, change its options. Object IDs are required attributes and must be created independently.

Using ObjectManager minimizes the browser resources spent. This is possible due to the following features of how the manager works:

  • Working with object overlays.
    The manager allows adding objects to the map without having to create geo objects — instances of the GeoObject class. The issue is that creating, rendering, and processing a geo object is an expensive operation in terms of resources spent. And if there are a thousand objects on the map, processing them significantly affects performance.

    When working with objects, the manager does not create geo objects, but immediately creates their overlay, which it then adds to the map. Overlays are visual representations of geo objects on the map, and processing them requires fewer resources than processing geo objects does.

  • Rendering only needed objects.
    The manager only creates overlays for the objects that fall within the map viewport.