Answer the question
In order to leave comments, you need to log in
Yandex.Maps API 2.0 why is there an Uncaught TypeError in the geoObjects method?
I need to make a route from one address to the one specified by the user (which he must find through the search bar, by analogy with the Yandex.Maps service itself).
I found such a solution ymapsapi.ya.ru/replies.xml?item_no=1501
, but when I try to add a code that builds a route to the render function in SearchAddress.MapView.prototype (I take an example from here https://tech.yandex.ru /maps/doc/jsapi/2.0/ref/refe... ), an Uncaught TypeError: Cannot read property 'geoObjects' of undefined is thrown .
What can be wrong?
Answer the question
In order to leave comments, you need to log in
Most likely, when copy-pasting, you do not check the names of variables.
// добавляем маршрут на карту
map.geoObjects.add(route);
// UDP
ymaps.route(
...
).then(function (route) {
...
// this в этом контексте является не тем объектом, о котором Вы думаете и у него нет свойства _map
map.geoObjects.add(route);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question