M
M
Maxymus19962018-06-01 17:49:29
JavaScript
Maxymus1996, 2018-06-01 17:49:29

How to change the color of the Yandex maps label when clicking on an external link?

When you click on the button, you need the corresponding label to change its image. When you click again, you need to return the default state. There is a code for the labels themselves, we need the implementation of their change on click.

<div class="button">Заголовок</div>
<div class="button">Заголовок</div>

<div class="map-shipping">
  <div id="map-shipping"></div>
</div>

<!-- jQuery -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

  <!-- Карта  -->
  <script src="https://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU"></script>
  <script>
    var myMap;
    ymaps.ready(init);

    function init () {
      myMap = new ymaps.Map('map-shipping', {
        center:[55.63651406908719,37.26042899999999],
        zoom:12
      });

      myMap.controls.add(new ymaps.control.ZoomControl());
      myMap.controls.add(new ymaps.control.MapTools());
      myMap.controls.add('scaleLine');
      myMap.controls.add('typeSelector');

      placemark = new ymaps.Placemark([55.63651406908719,37.26042899999999], {},

      {
        iconImageSize: [27, 38],
        cursor: 'pointer',
        iconShadow: true,
        iconImageHref: 'img/icons/map-marker.svg',
        balloonclose: true,

      });

      placemark2 = new ymaps.Placemark([55.63658689459852,37.27629785452268], {},

      {
        iconImageSize: [27, 38],
        cursor: 'pointer',
        iconShadow: true,
        iconImageHref: 'img/icons/map-marker.svg',
        balloonclose: true,

      });

      myMap.geoObjects.add(placemark);
      myMap.geoObjects.add(placemark2);

    }
  </script>

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