option.Manager

Options manager. For setting and getting option values by a string key, as well as allowing
option values in the context of the existing hierarchy of options managers.

The special "preset" key is for making a set of options by default for this manager.
The value of the "preset" option can be a hash with the format {"option name": "option value"}, or a string ID
for a hash of options in the option.presetStorage storage.
This hash of options can also contain a field named "preset", which allows for inheritance of option values
from other sets of options.

When searching for values in the hierarchy, first the options themselves are checked, then the options set using the "preset" key,
and after that the parent is accessed, if there is one.

// Example of building a hierarchy of options managers.
var parentManager = new ymaps.option.Manager({
key1: '123'
});
var childManager = new ymaps.option.Manager({
key2: '234'
}, parentManager);
// Outputs 123. The value is taken from manager1.
alert(childManager.get('key1'));
// Outputs 234. The value is taken from manager2.
alert(childManager.get('key2'));
// Overriding the option.
childManager.set('key1', '345');
// Outputs 345. The value is taken from manager2.
alert(childManager.get('key1'));
// Outputs 123. The value is taken from manager1.
alert(parentManager.get('key1'));

2.

// Example using the "preset" option.
var optionManager = new ymaps.option.Manager({
preset: 'islands#blueIcon'
});
var subOptionManager = new ymaps.option.Manager();
// There is no data, because subOptionManager is empty.
alert(subOptionManager.get('iconImageSize');
// Binding two managers.
subOptionManager.setParent(optionManager);
// [37, 42] - value is taken from the preset in the parent manager.
alert(subOptionManager.get('iconImageSize');
// Overriding the value of iconImageSize on the level of subOptionManager.
subOptionManager.set('iconImageSize', [10, 12]);
// [10, 12] - value is taken from subOptionManager.
alert(subOptionManager.get('iconImageSize');
// Canceling the override of iconImageSize.
subOptionManager.unset('iconImageSize');
// [37, 42] - value is again taken from the preset in the parent manager.
alert(subOptionManager.get('iconImageSize'));

Methods

Returns the value of the specified option in the context of the existing options inheritance hierarchy. When this method is called,
first values are searched for in the current options manager, then, if the value is not defined, the search continues
in the hierarchy of parent managers.

Returns the value of the specified option in the context of the existing options inheritance hierarchy. When this method is called,
first values are searched for in the current options manager, then, if the value is not defined, the search continues
in the hierarchy of parent managers.