S
S
Syomka Gavrilenko2017-10-01 14:37:48
JavaScript
Syomka Gavrilenko, 2017-10-01 14:37:48

How to go to a marker on the map by clicking on a link on the page?

Good afternoon!
I'm making art for organizations on the site and ran into a problem.

ymaps.ready(init);
    
    function init () {
      var myMap = new ymaps.Map('map', {
            center: [53.90102134685148, 27.57578697],
            zoom: 12,
            controls: ["zoomControl"]
        }),
        objectManager = new ymaps.ObjectManager({
          // Чтобы метки начали кластеризоваться, выставляем опцию.
          clusterize: true,
          // ObjectManager принимает те же опции, что и кластеризатор.
          gridSize: 32,
          clusterDisableClickZoom: true
        });

      // Чтобы задать опции одиночным объектам и кластерам,
      // обратимся к дочерним коллекциям ObjectManager.
      objectManager.objects.options.set('preset', 'islands#greenDotIcon');
      objectManager.clusters.options.set('preset', 'islands#greenClusterIcons');
      myMap.geoObjects.add(objectManager);

      $.ajax({
        url: MyAjax.ajaxurl,
        type: "GET",
        data: {
          action: 'map_organizations_list',
          security : MyAjax.security,
        },
        success: function(data){
          objectManager.add(data);
        },
      });
    }

On the same page there is a list of organizations
<div class="col-xs-12 col-sm-6 col-md-12 col-md-4 col-lg-3 org-list">
  <ul class="list-unstyled">
    <a href="#" class="toPoint" data-id="6">
      <li>
        <strong> Hillel</strong>
        <p>г. Минск, ул. В. Хоружей 28</p>
      </li>
    </a>
    <a href="#" class="toPoint" data-id="23">
      <li>
        <strong> Центр "Бейт-Симха"</strong>
        <p>г. Минск, ул. Шорная 20</p>
      </li>
    </a>
  </ul>
</div>

I want that when clicking on an organization in the list on the map, they go to the label of this organization and open the balloon of this organization.
data-id in link and label id are the same

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question