Map

Extends IDomEventEmitter.

Class for creating and managing a map.

Constructor | Fields | Events | Methods

Constructor

Map(parentElement, state[, options])

Creates a map instance.

Parameters:

Parameter

Default value

Description

parentElement*

Type: Object|String

Reference to an HTML element that contains the map, or the ID of this HTML element.

state*

Type: Object

Map parameters.

state.behaviors

['default']

Type: String[]

Enabled behaviors for the map. By default, the following are enabled: dragging the map and zooming the map by multitouch or double-click on touch screen devices; dragging the map with the mouse, double-click zooming and right-click area selection on all other devices. You can specify any keys supported by behavior.Manager.

state.bounds

Type: Number[][]

Geo coordinates of the viewport the map starts with. When initializing the map, you can set either a state.zoom-state.center pair, or this viewport. If state.bounds is set and the parameters state.zoom or state.center are also set, they will be ignored.

state.center

Type: Number[]

Geo coordinates of the map center. They must be set in conjunction with state.zoom.

state.controls

['default']

Type: String[]

The map controls, added by default. You can specify any keys supported by control.Manager. The list of available keys and default sets of controls are described in control.Manager.add.

state.margin

Type: Number|Number[]

Offsets from the map edges. Passed to map.margin.Manager.setDefaultMargin.

state.type

'yandex#map'

Type: String|MapType

Map type. Can be a key or an instance of the MapType class. List of available keys:

  • 'yandex#map' - "Roadmap" map type.
  • 'yandex#satellite' - "Satellite" map type.
  • 'yandex#hybrid' - "Hybrid" map type.

state.zoom

Type: Number

Map zoom level. It must be set in conjunction with state.center.

options

Type: Object

Map options. The map options can be used to make settings for the map itself, as well as for objects that are added to it:

  • Options for map behaviors.
  • Options for the map balloon with the balloon prefix.
  • Options for the map hint with the hint prefix.
  • Options for geo objects with the geoObject prefix.
  • Options for layers with the layer prefix.
  • Options for hotspot layers with the hotspotLayer prefix.
    Options that are interpreted directly by the map itself are listed below.

options.autoFitToViewport

'ifNull'

Type: String

Automatic map container tracking. By default, the map is automatically redrawn when it is initialized from a hidden container, or if we programmatically changed its dimensions; otherwise, you must call map.container.fitToViewport. The following values are available:

  • 'none' — Don't track changes to the container display when initialized from a hidden container or when its size is changed programmatically.
  • 'ifNull' — As soon as the container gets a CSS "display" value other than "none", map.container.fitToViewport executes automatically in order to fit the map to it. After this, tracking will stop.
  • 'always' — Always track changes to the display state of the map container.

options.avoidFractionalZoom

true

Type: Boolean

If true, the map does not stop on fractional values of the zoom level; if false, it does.

Note

By default, this option is true for desktop browsers and false for mobile browsers.

options.exitFullscreenByEsc

true

Type: Boolean

Enables to exit full-screen mode using the ESC button. If true, the map exits full-screen mode when the ESC button is pressed; if false, it does not.

options.fullscreenZIndex

10000

Type: Number

The value of the z-index property of the map container in full-screen mode.

options.mapAutoFocus

true

Type: Boolean

If true, clicking on the map will move the focus out of the currently active DOM element; if false, it will keep the focus on the active element.

options.maxAnimationZoomDifference

5

Type: Number

The maximum difference between the current map zoom level and the new zoom level so that zooming will look smooth.

options.maxZoom

23

Type: Number

Maximum map zoom level.

options.minZoom

0

Type: Number

Minimum map zoom level.

options.nativeFullscreen

false

Type: Boolean

Use the native fullscreen "mode" if possible. Switching to the native full screen mode means that the browser asks the user if they want to go into "fullscreen mode" and if the user agrees, expands the map to full screen, and hides browser controls. The user can exit the mode by pressing the ESC key. The fullscreenZIndex and exitFullscreenByEsc options have no effect in the native "fullscreen mode".

options.projection

ymaps.projection.wgs84Mercator

Type: IProjection

Map projection.

options.restrictMapArea

false

Type: Boolean|Number[][]

Sets the map viewport so that the user cannot leave the viewport area. True — Set the area to match the current display area; false — disable this option. If you need to restrict an area with known coordinates, specify this rectangular area.

options.suppressMapOpenBlock

false

Type: Boolean

Whether to hide the offer to open the current map in Yandex Maps with all the available map information preserved as completely as possible. True - hide; false - don't hide. The link to Yandex Maps is displayed in the lower-left corner of the map.

options.suppressObsoleteBrowserNotifier

false

Type: Boolean

Whether to hide the notification suggesting a browser upgrade that is shown in outdated browsers. True - hide; false - don't hide. This notification is displayed in the lower-left corner of the map.

options.yandexMapAutoSwitch

true

Type: Boolean

true - Enable automatically switching to the Map Editor in those places where the map is not detailed enough; false - disable. This option only works for lang=ru_RU and lang=uk_UA.

options.yandexMapDisablePoiInteractivity

false

Type: boolean

True - disable interactivity of POI (points of interest) in the map's base layer, false — enable.

* Mandatory parameter/option.

Examples:

1.

// Initializing a map with a known center and zoom level.
var myMap = new ymaps.Map('map', {
    center: [55.74954, 37.621587],
    zoom: 10
});

2.

// Initializing a map with a known view area.
// We assume that jQuery is enabled on the page.
var $mapElement = $('#map');
var myMap = new ymaps.Map(
    $mapElement[0],
    ymaps.util.bounds.getCenterAndZoom(
        [[55.7, 37.6], [55.8, 37.7]],
        [$mapElement.width(), $mapElement.height()]
    )
);

3.

// Initializing a map from geocoding results.
var myMap;
ymaps.geocode('Moscow').then(function (res) {
    myMap = new ymaps.Map('map', {
        center: res.geoObjects.get(0).geometry.getCoordinates(),
        zoom : 10
    });
});

Fields

Name

Type

Description

action

map.action.Manager

Map actions manager.

balloon

map.Balloon

Map balloon.

behaviors

map.behavior.Manager

Map behaviors manager. Enables and disables behaviors, and also provides access to their methods and properties.

container

map.Container

Map container.

controls

control.Manager

Map controls.

converter

map.Converter

Converts map pixel points from global to local and back.

copyrights

map.Copyrights

Manager for copyright information on the map.

cursors

util.cursor.Manager

Map cursors manager.

events

event.Manager

Map event manager. Supports subscriptions with priorities. Throws an event of the MapEvent type.

geoObjects

map.GeoObjects

Manager for map geo objects.

hint

map.Hint

Map hint.

layers

map.layer.Manager

Map layers manager.

margin

map.margin.Manager

Map margins manager.

options

option.Manager

Map options.

panes

map.pane.Manager

Manager for map object containers.

zoomRange

map.ZoomRange

Object that provides access to information about available zoom levels at a point.

Events

Name

Description

actionbegin

The start of a new smooth map movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - Action that has started.

actionbreak

Event that occurs when an action step was prematurely stopped (for example, because another action or another step of the action was performed). Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - An action.

actionend

The end of smooth map movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - Action that has stopped.

actiontick

The start of a new step of smooth movement (for example, the user shifting the map, or a step of animated smooth zooming). Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - The action being performed at this moment.
  • tick - Description of an action step in the form of an object with the fields "globalPixelCenter", "zoom", "duration" and "timingFunction".

actiontickcomplete

The end of performing a step of smooth movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - The action being performed at this moment.
  • tick - Description of an action step in the form of an object with the fields "globalPixelCenter", "zoom", "duration" and "timingFunction".

balloonclose

Closing the balloon. Instance of the Event class.

balloonopen

Opening a balloon on a map. Instance of the Event class.

boundschange

Event for a change to the map viewport (as the result of changing the center or zoom level). Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldCenter - The previous map center, in geo coordinates.
  • newCenter - The new map center, in geo coordinates.
  • oldZoom - The previous zoom level.
  • newZoom - The new zoom level.
  • oldGlobalPixelCenter - The previous map center, in global pixels.
  • newGlobalPixelCenter - The new map center, in global pixels.
  • oldBounds - Previous viewport.
  • newBounds - New viewport.

click

Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

contextmenu

Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

dblclick

Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

destroy

The map was destroyed.

hintclose

Closing the hint. Instance of the Event class.

hintopen

Opening a hint on a map. Instance of the Event class.

marginchange

Map margins changed. Instance of the Event class.

mousedown

Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseenter

Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseleave

Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mousemove

Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseup

Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

multitouchend

End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface.

Inherited from IDomEventEmitter.

multitouchmove

Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

multitouchstart

Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

optionschange

Map options changed.

sizechange

Map size changed. Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldSize - The previous size of the map.
  • newSize - The new size of the map.

typechange

The map type changed. Instance of the Event class.

wheel

Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

Methods

Name

Returns

Description

destroy()

Destroys the map.

getBounds([options])

Number[][]

Returns a two-dimensional array of geo coordinates for the lower-left and upper-right corners of the map viewport.

getCenter([options])

Number[]

Returns geographical coordinates of the current map center.

getGlobalPixelCenter([options])

Number[]

Returns global pixel coordinates of the current map center.

getPanoramaManager()

vow.Promise.<panorama.Manager>

Returns vow.Promise, which will be resolved with The panorama manager for the map. If an error occurs, the promise object is rejected.

getType()

String|MapType

Returns the current map type.

getZoom()

Number

Returns the current map zoom.

panTo(center[, options])

vow.Promise

Sets the map center. If an array of points is passed, the map will move from one point to the other.

setBounds(bounds[, options])

vow.Promise

Positions the map for displaying the region that was passed.

setCenter(center[, zoom[, options]])

vow.Promise

Sets the map center and zoom level. The center is set in geographical coordinates.

setGlobalPixelCenter(globalPixelCenter[, zoom[, options]])

vow.Promise

Sets the map center and zoom level. The center is set in global pixel coordinates.

setType(type[, options])

vow.Promise

Sets the map type.

setZoom(zoom[, options])

vow.Promise

Sets the map zoom level.

Fields details

action

{map.action.Manager} action

Map actions manager.

Example:

var myAction = new ymaps.map.action.Single({
    center: [0, 0],
    zoom: 4,
    duration: 1000,
    timingFunction: "ease-in"
});

myMap.action.execute(myAction);

balloon

{map.Balloon} balloon

Map balloon.

behaviors

{map.behavior.Manager} behaviors

Map behaviors manager. Enables and disables behaviors, and also provides access to their methods and properties.

Example:

// Enabling mouse wheel zooming.
myMap.behaviors.enable('scrollZoom');

container

{map.Container} container

Map container.

Example:

// Adjusting the map size to the new size of the container
// (for example, if the page layout changed or the map was initialized
// in the hidden state).
map.container.fitToViewport();

controls

{control.Manager} controls

Map controls.

Example:

myMap.controls.add('zoomControl', {
    float: 'none',
    position: {
        right: 40,
        top: 5
    }
});

converter

{map.Converter} converter

Converts map pixel points from global to local and back.

Example:

// Converting the mouse coordinates to geographical coordinates.
var projection = map.options.get('projection');
$('#map').bind('click', function (e) {
    console.log(projection.fromGlobalPixels(
        map.converter.pageToGlobal([e.pageX, e.pageY]), map.getZoom()
    ));
});

copyrights

{map.Copyrights} copyrights

Manager for copyright information on the map.

Example:

// Adding author information.
map.copyrights.add('© Jimmy John');

cursors

{util.cursor.Manager} cursors

Map cursors manager.

Example:

// Adding the "Help" cursor to the map.
var accessor = map.cursors.push('help');
// ...
// Removing the cursor.
accessor.remove();

events

{event.Manager} events

Map event manager. Supports subscriptions with priorities. Throws an event of the MapEvent type.

Examples:

1.

// Adding a placemark in response to a click on the map.
map.events.add('click', function (e) {
    // To get the geographical coordinates of the point of click,
    // call the get('coords') method.
    var position = e.get('coords');
    map.geoObjects.add(new ymaps.Placemark(position));
});

2.

// Tracking the map's center and zoom during smooth movements.
map.events.add('actiontick', function () {
    var state = map.action.getCurrentState();
    console.log(state.zoom, state.globalPixelCenter);
});

geoObjects

{map.GeoObjects} geoObjects

Manager for map geo objects.

hint

{map.Hint} hint

Map hint.

layers

{map.layer.Manager} layers

Map layers manager.

See Layer

Example:

// Adding a layer of custom tiles to the map.
map.layers.add(new ymaps.Layer('http://some.server/tiles?&amp;c'));

margin

{map.margin.Manager} margin

Map margins manager.

options

{option.Manager} options

Map options.

Example:

// Forbidding all objects on the map to open balloons on mouse clicks.
map.options.set('openBalloonOnClick', false);

panes

{map.pane.Manager} panes

Manager for map object containers.

Example:

// Adding a custom element to the map controls container.
$('<div><input type="button" value="Click!"/></div>')
    .css({ position: 'absolute', left: '5px', top: '50px'})
    .appendTo(map.panes.get('controls').getElement());

zoomRange

{map.ZoomRange} zoomRange

Object that provides access to information about available zoom levels at a point.

Example:

// Getting the maximum available map zoom level
// at the point [20, 30].
map.zoomRange.get([20, 30]).then(function (zoomRange) {
    alert(zoomRange[1]);
});

Events details

actionbegin

The start of a new smooth map movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - Action that has started.

actionbreak

Event that occurs when an action step was prematurely stopped (for example, because another action or another step of the action was performed). Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - An action.

actionend

The end of smooth map movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - Action that has stopped.

actiontick

The start of a new step of smooth movement (for example, the user shifting the map, or a step of animated smooth zooming). Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - The action being performed at this moment.
  • tick - Description of an action step in the form of an object with the fields "globalPixelCenter", "zoom", "duration" and "timingFunction".

Example:

// Tracks all map movement, even user dragging
// and smooth zooming.
map.events.add('actiontick', function (e) {
    var tick = e.get('tick');
    console.log('Now the map is moving to the point (' +
        map.options.get('projection').fromGlobalPixels(tick.globalPixelCenter, tick.zoom).join(',') +
        ') during ' + e.get('tick').duration + ' milliseconds');
});

actiontickcomplete

The end of performing a step of smooth movement. Instance of the Event class. Names of fields that are available via the Event.get method:

  • action - The action being performed at this moment.
  • tick - Description of an action step in the form of an object with the fields "globalPixelCenter", "zoom", "duration" and "timingFunction".

balloonclose

Closing the balloon. Instance of the Event class.

balloonopen

Opening a balloon on a map. Instance of the Event class.

boundschange

Event for a change to the map viewport (as the result of changing the center or zoom level). Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldCenter - The previous map center, in geo coordinates.
  • newCenter - The new map center, in geo coordinates.
  • oldZoom - The previous zoom level.
  • newZoom - The new zoom level.
  • oldGlobalPixelCenter - The previous map center, in global pixels.
  • newGlobalPixelCenter - The new map center, in global pixels.
  • oldBounds - Previous viewport.
  • newBounds - New viewport.

Example:

// Tracking changes to the map zoom level.
map.events.add('boundschange', function (event) {
    if (event.get('newZoom') != event.get('oldZoom')) {
        alert('Zoom level changed');
    }
});

destroy

The map was destroyed.

hintclose

Closing the hint. Instance of the Event class.

hintopen

Opening a hint on a map. Instance of the Event class.

marginchange

Map margins changed. Instance of the Event class.

optionschange

Map options changed.

sizechange

Map size changed. Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldSize - The previous size of the map.
  • newSize - The new size of the map.

typechange

The map type changed. Instance of the Event class.

Methods details

destroy

{} destroy()

Destroys the map.

getBounds

{Number[][]} getBounds([options])

Returns a two-dimensional array of geo coordinates for the lower-left and upper-right corners of the map viewport.

Parameters:

Parameter

Default value

Description

options

Type: Object

Options.

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

getCenter

{Number[]} getCenter([options])

Returns geographical coordinates of the current map center.

Parameters:

Parameter

Default value

Description

options

Type: Object

Options.

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

getGlobalPixelCenter

{Number[]} getGlobalPixelCenter([options])

Returns global pixel coordinates of the current map center.

Parameters:

Parameter

Default value

Description

options

Type: Object

Options.

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

Example:

// Shifting the map 10 pixels left.
var position = map.getGlobalPixelCenter();
map.setGlobalPixelCenter([ position[0] - 10, position[1] ]);

getPanoramaManager

{vow.Promise.<panorama.Manager>} getPanoramaManager()

Returns vow.Promise which:

  • will be resolved with: <panorama.Manager> — The panorama manager for the map;
  • either rejected with an error.

getType

{String|MapType} getType()

Returns the current map type.

getZoom

{Number} getZoom()

Returns the current map zoom.

panTo

{vow.Promise} panTo(center[, options])

Sets the map center. If an array of points is passed, the map will move from one point to the other.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

center*

Type: Number[]|Object[]

The map center or an array of points to move through sequentially.

options

Type: Object

Options.

options.checkZoomRange

false

Type: Boolean

Checks whether the current zoom can be set after moving the map center. If the value of this option is "true", the method is called asynchronously. A request is sent to the server, which returns the range of acceptable zoom values for the given center. After this, the specified center and appropriate zoom are applied.

options.delay

1000

Type: Number

The delay time between moves, in milliseconds.

options.duration

500

Type: Number

Animation duration, in milliseconds.

options.flying

true

Type: Boolean

Allows decreasing and then increasing the map zoom when moving between points. If the distance between points is less than twice the size of the map container, the map smoothly moves the center to the specified point without changing the zoom level. If the distance is more, the map applies a smaller zoom level, then moves to the destination point and applies the required zoom level (emulates flying over the map).

options.safe

true

Type: Boolean

Shifts the map safely. You can only use it if the "flying" option is false. If the distance between points is less than twice the size of the map container, the map smoothly moves the center to the specified point. If the distance exceeds that value, the map instantly moves to the selected point. Use this mode to conveniently move the map without displaying unloaded tiles.

options.timingFunction

'ease-in-out'

Type: String

Timing function. The same as the value of the CSS property transition-timing-function. Full list of values: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

// Flight from Kaliningrad to Vladivostok via Moscow.
map.setCenter([54.704815, 20.466380], 10);
map.panTo([
    [55.751574, 37.573856],
    [43.134091, 131.928478]
]).then(function () {
   alert('Landed!');
}, function (err) {
   alert('An error occurred ' + err);
}, this);

setBounds

{vow.Promise} setBounds(bounds[, options])

Positions the map for displaying the region that was passed.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

bounds*

Type: Number[][]

Boundaries of the viewport, specified by the coordinates of the lower-left and upper-right corners of the view area.

options

Type: Object

Options.

options.checkZoomRange

false

Type: Boolean

Checks whether the specified zoom level can be set. If the value of this option is "true", the method is called asynchronously. A request is sent to the server, which returns the range of acceptable zoom values for the given center. After this, the specified center and appropriate zoom are applied.

options.duration

0

Type: Number

Animation duration, in milliseconds.

options.preciseZoom

false

Type: Boolean

The ability to use fractional zoom levels.

options.timingFunction

'linear'

Type: String

Timing function. The same as the value of the CSS property transition-timing-function. Full list of values: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

options.zoomMargin

0

Type: Number|Number[]

Offset from the borders of the visible area of the map. If a single number is set, it is applied to each side. If two numbers are set, they are the horizontal and vertical margins, respectively. If an array of four numbers is set, they are the top, right, bottom, and left margins. When the "useMapMargin" option is enabled, the "zoomMargin" value is combined with the values that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

// The new map center and zoom level are calculated based on the current
// map state.
// If the current zoomRange does not match the zoomRange for the new map center,
// grey tiles may be displayed if the viewport is very small.
// To avoid this problem, use the checkZoomRange option.
map.setBounds([[60,-40], [20,60]], {
   checkZoomRange: true,
}).then(function () {
      // Action has completed successfully.
   }, function (err) {
      // Specified region could not be shown
      // ...
   }, this);

setCenter

{vow.Promise} setCenter(center[, zoom[, options]])

Sets the map center and zoom level. The center is set in geographical coordinates.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

center*

Type: Number[]

Geo coordinates of the map center.

zoom

Type: Number

Map zoom level.

options

Type: Object

Options.

options.checkZoomRange

false

Type: Boolean

Checks whether the specified zoom level can be set. If the value of this option is "true", the method is called asynchronously. A request is sent to the server, which returns the range of acceptable zoom values for the given center. After this, the specified center and appropriate zoom are applied.

options.duration

0

Type: Number

Animation duration, in milliseconds.

options.timingFunction

'linear'

Type: String

Timing function. The same as the value of the CSS property transition-timing-function. Full list of values: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

myMap.setCenter([40, 50], 3, {
    checkZoomRange: true
});

setGlobalPixelCenter

{vow.Promise} setGlobalPixelCenter(globalPixelCenter[, zoom[, options]])

Sets the map center and zoom level. The center is set in global pixel coordinates.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

globalPixelCenter*

Type: Number[]

Pixel coordinates of the new map center.

zoom

Type: Number

Map zoom level.

options

Type: Object

Options.

options.checkZoomRange

false

Type: Boolean

Checks whether the specified zoom level can be set. If the value of this option is "true", the method is called asynchronously. A request is sent to the server, which returns the range of acceptable zoom values for the given center. After this, the specified center and appropriate zoom are applied.

options.duration

0

Type: Number

Animation duration, in milliseconds.

options.timingFunction

'linear'

Type: String

Timing function. The same as the value of the CSS property transition-timing-function. Full list of values: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

// Shifting the map 10 pixels left.
var position = map.getGlobalPixelCenter();
map.setGlobalPixelCenter([ position[0] - 10, position[1] ]);

setType

{vow.Promise} setType(type[, options])

Sets the map type.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

type*

Type: String|MapType

Map type. Can be a key or an instance of the MapType class. List of available keys:

  • 'yandex#map' - "Roadmap" map type.
  • 'yandex#satellite' - "Satellite" map type.
  • 'yandex#hybrid' - "Hybrid" map type.

options

Type: Object

Map options.

options.checkZoomRange

false

Type: Boolean

Checks if the specified map type can be set at the specified zoom level. When set to "true", a request is sent to the server, which returns the range of acceptable zoom values for the given map type. After this, the specified center and appropriate zoom are applied.

* Mandatory parameter/option.

Example:

map.setType('yandex#hybrid', {
   checkZoomRange: true
}).then(function () {
   // The map type has been set with the acceptable zoom level.
}, this);

setZoom

{vow.Promise} setZoom(zoom[, options])

Sets the map zoom level.

Returns Promise object. If the action completed successfully, returns "resolve" without a value. If an error occurred, returns "reject" with the error description.

Parameters:

Parameter

Default value

Description

zoom*

Type: Number

Map zoom level.

options

Type: Object

Options.

options.checkZoomRange

false

Type: Boolean

Checks whether the specified zoom level can be set.

options.duration

0

Type: Number

Animation duration, in milliseconds.

options.useMapMargin

false

Type: Boolean

Whether to use offsets that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

myMap.setZoom(4, {duration: 1000});