---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/modules.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/dg/concepts/modules.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# Modular system

The Yandex Maps API was developed using a modular concept.

The modules are separate named entities, such as classes, static objects, and functions. A list of API modules is provided in the [Reference guide](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/concepts/About.md).

{% note info %}

When enabling modules, you only need to specify the ones that will be accessed in the code via the `ymaps` namespace.

{% endnote %}

The API allows you to add new modules to the module system.

## Loading modules when enabling the API {#load}

The modules to load are set in the HTTP parameter `load` in the string for [enabling the API](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/load.md). You can specify multiple modules by separating them with spaces. By default, the `load` parameter takes the `package.full` value, meaning it loads all the main modules that are needed by the API.

```xml

```

The loaded modules will be enabled in the public namespace `ymaps`.

If additional modules are required for the given modules to work, they will be loaded automatically.

The [Sandbox](http://api.yandex.ru/maps/jsbox/2.1/load_modules) has an example of loading modules via the `load` parameter.

## Loading modules on demand {#require}

Sometimes a module needs to be loaded on demand. Use the [modules.require](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/modules.require.md) function for this purpose:

```javascript
if (!ymaps.Map) {
    ymaps.**modules.require**(['Map', 'Placemark'], function (Map, Placemark) {
         // Adding the class manually to the global viewport, since this doesn't happen when using the module system's "require" method.
        ymaps.Map = Map;
        var map = new ymaps.Map('map', { 
              center: [55.76, 37.64], 
              zoom: 10    
            }),
            // The Placemark class wasn't added to the public viewport.
            placemark = new Placemark([55.55, 37.00]);
        map.geoObjects.add(placemark);
    })
    /* The placemark won't be created because the Placemark class isn't included in ymaps.
    var newPlacemark = new ymaps.Placemark([55.50, 37.00]); 
    */
}
</script>
```

Since these modules may require loading additional modules in order to work, the `modules.require` function supports asynchronous mode. When the data needed by the specified modules is ready, it calls the callback function with the loaded modules.

The [Sandbox](http://api.yandex.ru/maps/jsbox/2.1/module_request) has an example of loading modules on demand.

## Enabling add-ons {#addons}

Displaying a geo object's balloon and hint is performed using the `balloon` and `hint` fields for the [GeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObject.md) class. To initialize these fields, you must enable the modules [geoObject.addon.balloon](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geoObject.addon.balloon.md) and [geoObject.addon.hint](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geoObject.addon.hint.md). If you need to open a balloon or hint that belongs to the map, you need to enable the [map.addon.balloon](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.addon.balloon.md) and [map.addon.hint](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.addon.hint.md) modules.

If you need to be able to edit a geo object's geometry, you should enable [geoObject.addon.editor](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geoObject.addon.editor.md).

The [Sandbox](http://api.yandex.ru/maps/jsbox/2.1/load_modules) has an example of enabling add-ons.

## Creating custom modules {#define}

You can use the API module system to create custom programmatic modules. This is useful when writing large-scale applications based on the Yandex Maps API.

The module is declared using the [modules.define](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/modules.define.md) method. The [Sandbox](http://api.yandex.ru/maps/jsbox/2.1/custom_module) has an example of declaring and using a custom module.

The module declaration can be made before calling the [ymaps.ready](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ready.md) handler.

After the module has been declared in the module system, it can be used in an application.

{% note info %}

Custom modules are not added automatically in the general namespace with the API modules. A declared module can be accessed via the asynchronous [modules.require](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/modules.require.md) method, which returns a promise object.

{% endnote %}

```javascript
ymaps.modules.require(['PlacemarkButton'])
  .spread(function (PlacemarkButton) {
    myMap.controls.add(new PlacemarkButton('Click to add a placemark'));
});
```

