如何获取当前地图坐标?

how to get the current map coordinates?

我在页面上有 yandex 地图。对于这张地图,我绑定事件处理程序 'actionend'.

我需要在此处理程序中获取地图中心的当前坐标。请帮我搞定。

live demo here.

代码:

ymaps.ready(init);

var myMap;

function init(){     
    myMap = new ymaps.Map("map", {
        center: [55.76, 37.64],
        controls: [],
        zoom: 18
    });   

    myMap.events.add('actionend', function (e) {
        console.log('stop action');
        console.log('print current coords of map center???????????????');
    });
};

你可以通过调用getCenter()方法得到中心坐标,像这样:

ymaps.ready(init);

var myMap;

function init(){     
    myMap = new ymaps.Map("map", {
        center: [55.76, 37.64],
        controls: [],
        zoom: 18
    });   

    myMap.events.add('actionend', function (e) {
       console.log(e.originalEvent.map.getCenter())
    });
};

看到这个doc