A
A
A E2014-12-01 15:21:27
API
A E, 2014-12-01 15:21:27

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

1 answer(s)
E
Evgeny Kumanin, 2014-12-02
@Kunj

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);
 });

The error means: There is no geoObjects property on the undefined object. And undefined means that the map variable is not defined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question