V
V
Vladimir Golub2019-03-27 13:20:54
JavaScript
Vladimir Golub, 2019-03-27 13:20:54

How to get the current zoom of the map if it was created using bounds?

I do it like this:

<YMaps
  onApiAvaliable={(ymaps) => this.handleApiAvaliable(ymaps)}
>

Then I get this object:
handleApiAvaliable(ymaps) {
    console.log(ymaps);
}

But I can't find where exactly is the zoom in it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-03-27
@RazerVG

You need to get through the map object created by the constructor, in this case myMap

var myMap;
...
myMap = new ymaps.Map(...)
...
zoom = myMap.getZoom()

in most examples, myMap is a local variable, so you must declare it as a global variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question