Answer the question
In order to leave comments, you need to log in
How to implement zooming when clicking on a label (Yandex.Map 2.0)?
Tell me how to zoom in on the map when you click on the Placemark
When you click on the show button on the map, the zoom occurs, but I can’t figure out how to do the same feature for the marker
<ul class="addresses">
<li>
<a class="map-link" data-index="0" data-c1="54.229275" data-c2="28.506697" href="exemple.html#top">Показать на карте</a>
</li>
</ul>
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
<script type="text/javascript">
var map;
ymaps.ready(function () {
map = new ymaps.Map ("map", {center: [54.229275,28.506697], zoom: 7});
map.controls.add(new ymaps.control.ZoomControl());
map.controls.add(new ymaps.control.TypeSelector(['yandex#map', 'yandex#publicMap']));
var myPlacemark = new ymaps.Placemark(map.getCenter(), {hintContent: ''}, {iconImageHref: '[(base_url)]assets/images/dealer.png',iconImageSize: [23,30]});
map.geoObjects.add(myPlacemark);
$('.addresses .map-link').bind('click', function () {
$('.addresses .map-link').removeClass('active');
$(this).addClass('active');
var c1, c2;
c1 = $(this).attr('data-c1');
c2 = $(this).attr('data-c2');
map.setCenter([c1, c2], 15);
});
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question