V
V
Vladislav2014-08-06 16:51:24
Yandex maps
Vladislav, 2014-08-06 16:51:24

How to open a balloon on Yandex.Maps using a link?

Situation:
there is a map with marks. When you click on a link from outside, you need to open the balloon of a certain label.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Lobanov, 2014-08-06
@MacLaud

upd:

if (window.location.hash != '') {
     var hash = window.location.hash.substr(1);
         pm = ymaps.geoQuery(myGeoObjects).search('properties.name == "' + hash + '"').getCenter(myMap);
     myMap.setCenter(pm);
}

In the example, I replaced the hash with just one of the name values ​​to show it clearly.
codepen.io/iiil/pen/AtkLn?editors=001
Study this: api.yandex.ru/maps/doc/jsapi/2.0/ref/reference/Geo...
Maybe you want to process the search result
differently elementary indeed. In the hash, put the name or id of the balloon, when you open the page, put it in a variable, and when loading the map, look for this balloon and, if it exists, put it in the center of the map using the API.

V
Vladislav, 2014-08-07
@MacLaud

Well, how can I get to the balloon through name if they are created like this:

myGeoObjects[0] = new ymaps.Placemark([56.044132, 37.594707], {
  name: '693',
  balloonContentBody: "Описание объекта"			    
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question