Answer the question
In order to leave comments, you need to log in
How to make the map show this place when you click on the desired address?
It is necessary to implement something similar to how on this site angelovo.academy, click on the "addresses" menu item.
By clicking on the table with addresses, the Yandex map changes its content and shows the address you need.
How to do it?
Answer the question
In order to leave comments, you need to log in
Info in the dock: https://tech.yandex.ru/maps/doc/jsapi/2.0/ref/ref...
Example from the docks:
// Полёт из Калининграда во Владивосток через Москву
map.setCenter([54.704815, 20.466380], 10);
map.panTo([
[ 55.751574, 37.573856 ],
[ 43.134091, 131.928478 ]
], {
callback: function () {
alert('Прилетели!');
}
});
document.querySelector('#showMap_1').addEventListener('click', function() {
myMap.setZoom( 15 );
myMap.panTo([55.66837606904998,37.484163499999944],{flying:1});
});
Strictly speaking, the principle of "do not repeat yourself" is violated.
on the site example for each individual selector the same code, only the number of coordinates change.
it goes without saying that these correspondences should be placed in a separate js-object of the form
var coords = {
'showMap_1':{
[55.66837606904998,37.484163499999944]
},
'showMap_2':{
[55.66266356906509,37.478000999999914]
},
...
}
$('tr[id=^showMap]').click(function() {
myMap.setZoom( 15 );
myMap.panTo(coords[$(this).attr('id')],{flying:1});
TweenMax.to(window, 0.5, {scrollTo:{y: document.getElementById("map").offsetTop-10}})
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question