Answer the question
In order to leave comments, you need to log in
How to deal with "cannot read property panTo of undefined" in YaMaps?
Good afternoon.
I'm trying to set up a map in the Bitrix component so that when a city is selected, the map moves to the required coordinates, but I get this error
Uncaught TypeError: Cannot read property 'panTo' of undefined(…)
Answer the question
In order to leave comments, you need to log in
The problem was solved by writing a function in script.js in the map template
function click(map){
$(".town-select").on('click', 'a', function () {
map.panTo([$(this).data('coords').split(',')], {flying: true});
})
}
map.geoObjects.add(obPlacemark);
click(map);
return obPlacemark;
У меня работает такая конструкция. Я не уверен, может быть дело в версии подключенного апи. Вторая версия поддерживает точно panTo.
myMap.panTo([56.13238398110529,40.408], {
flying: 1
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question