Documentation
Reference
2.1.56 (current version)
collection
interactivityModel
Interfaces

Map

Extends IDomEventEmitter.

Class for creating and managing a map.

Constructor | Fields | Events | Methods

Constructor

Creates a map instance.

Parameters:

ParameterDefault valueDescription
parentElement *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object|String

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

state *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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 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

To 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, hides browser controls and allows the user to exit the mode by pressing 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 Public Map 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 by a known view area
// We assume that jQuery is enabled on the page
var $mapElement = $('#map'),
    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

NameTypeDescription
actionmap.action.Manager

Map actions manager.

balloonmap.Balloon

Map balloon.

behaviorsmap.behavior.Manager

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

containermap.Container

Map container.

controlscontrol.Manager

Map controls.

convertermap.Converter

Converts map pixel points from global to local and back.

copyrightsmap.Copyrights

Manager for copyright information on the map.

cursorsutil.cursor.Manager

Map cursors manager.

eventsevent.Manager

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

geoObjectsmap.GeoObjects

Manager for map geo objects.

hintmap.Hint

Map hint.

layersmap.layer.Manager

Map layers manager.

marginmap.margin.Manager

Map margins manager.

optionsoption.Manager

Map options.

panesmap.pane.Manager

Manager for map object containers.

zoomRangemap.ZoomRange

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

Events

NameDescription
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 animating 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 changing 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 geocoordinates.
  • newCenter - The new map center, in geocoordinates.
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

Methods

NameReturnsDescription
destroy()

Destroys the map.

getBounds([options])

Number[][]

Returns a two-dimensional array of geocoordinates 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 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 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('&amp;copy; Jimmy John');

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 on a click on the map
map.events.add('click', function (e) {
    // To get the geographical coordinates of the point of click,
    // call .get('coords')
    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 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 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

Manager for map object containers.

Example:

// Adding a custom element to the map controls container
$('&lt;div&gt;&lt;input type=&quot;button&quot; value=&quot;Click!&quot;/&gt;&lt;/div&gt;')
    .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 animating 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 changing 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 geocoordinates.
  • newCenter - The new map center, in geocoordinates.
  • 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 geocoordinates for the lower-left and upper-right corners of the map viewport.

Parameters:

ParameterDefault valueDescription
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:

ParameterDefault valueDescription
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:

ParameterDefault valueDescription
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

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:

ParameterDefault valueDescription
center*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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

Allow 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:

ParameterDefault valueDescription
bounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

Boundaries of the viewport.

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:

ParameterDefault valueDescription
center*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
globalPixelCenter*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
type*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
zoom*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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});