Answer the question
In order to leave comments, you need to log in
How to keep the label centered when moving the map?
I use the react-yandex-map library to work with Yandex maps. I can’t fix the label in the center when dragging the map (you need to do it like a Yandex taxi, they always have a label when dragging in the center), I looked at the official dock, I didn’t find anything there.
Answer the question
In order to leave comments, you need to log in
const [ coord, setCoord ] = useState(...);
function onActionTickComplete(e) {
const projection = e.get('target').options.get('projection');
const { globalPixelCenter, zoom } = e.get('tick');
setCoord(projection.fromGlobalPixels(globalPixelCenter, zoom));
}
<Map
onActionTickComplete={onActionTickComplete}
...
>
<Placemark geometry={coord} />
</Map>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question