V
V
Vampre2018-08-22 16:44:28
JavaScript
Vampre, 2018-08-22 16:44:28

How to determine the parameters of Yandex Maps depending on the marks on the map?

When we add a Yandex map to the site, we indicate the coordinates of the center and the zoom, but let's say I have three marks on the map and I need the map to be configured so that ideally all these three marks fall and that's it. I see it this way - before rendering, you need to determine, based on the labels, somehow the middle and the zoom. I have not worked with geodata before, if anyone has experience, please tell me how best to do it all.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-08-22
@Vampre

map.setBounds(map.geoObjects.getBounds())
jsfiddle.net/mw52nqrp
Or, if there are other marks on the map besides the ones you are interested in, put the necessary marks into a GeoObjectCollection and call getBounds on this collection:
jsfiddle.net/8941pawj

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question