I do everything like this:

ymaps.ready(init); function init () { var myMap = new ymaps.Map('yamap', { center: [{{ $cityfull->coordinats }}], zoom: 10 }, { searchControlProvider: 'yandex#search' }), objectManager = new ymaps.ObjectManager({ clusterize: true, gridSize: 32, clusterDisableClickZoom: true }); objectManager.objects.options.set('preset', 'islands#greenDotIcon'); objectManager.clusters.options.set('preset', 'islands#greenClusterIcons'); myMap.geoObjects.add(objectManager); var url = window.location.href+'?json'; $.ajax({ url: url }).done(function(data) { objectManager.add(data); myMap.setBounds(myMap.geoObjects.getBounds()); }); } 

myMap.setBounds (myMap.geoObjects.getBounds ());

It does not work, but rather it works like this:

enter image description here

  • 2
    It works for me: jsfiddle.net/fpqm78gt , you need to look at your data. The best option would be to fix the example above to start playing. - se0ga
  • Well, I found a problem. The card is in a hidden block. Therefore, it was actually necessary to perform setBounds after its appearance, but thanks. We came up with an idea to look elsewhere)) - Shevtsov Eugene

1 answer 1

I will add, as the search engine brought here, and this may be useful.

There was a similar situation - the map is in a hidden tab. Comments on this issue helped to solve this intimate problem. In my case

 $('#tabs').bind('tabsshow', function (event, ui) { myMap.container.fitToViewport(); myMap.setBounds(myMap.geoObjects.getBounds()); }); 
New member
Andrey Tinyakov is a new member of the site. Be lenient in asking clarifying questions, commenting and answering. Read about the norms of behavior .