Answer the question
In order to leave comments, you need to log in
How to get the coordinate when moving the map?
It seems that you need to use the actiontickcomplete event - there you can get event.get('tick') in which there will be a globalPixelCenter - but I need the coordinate just before the map stops moving
* Setting the marker to the center of the map as in Yandex.Taxi - so that the marker always remains in the center maps, even when the map is moving
Answer the question
In order to leave comments, you need to log in
I had the same task. Decided like this:
window.myMap = new ymaps.Map('map', {
controls: [],
center: coordinates,
zoom: 11,
});
const centerPoint = new ymaps.Placemark(coordinates, {}, {
preset: 'islands#whiteStretchyIcon',
});
myMap.events.add('actiontickcomplete', (event) => {
const { globalPixelCenter, zoom } = event.get('tick');
const projection = myMap.options.get('projection');
const coords = projection.fromGlobalPixels(globalPixelCenter, zoom);
centerPoint.geometry.setCoordinates(coords);
});
myMap.geoObjects.add(centerPoint);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question