S
S
stcmd042362017-08-04 11:30:20
JavaScript
stcmd04236, 2017-08-04 11:30:20

How to use async in JavaScript?

Good day to all! There is this code:

// получаем дистанцию
function getDistance(c, center,geoObject){
    layout.showLoading();
    var a = [];
    routeFromCenter(c,function(g,l){
        a.push(l[0]);
        var q = findNereast(jGq, c, 1),
            n = [],
            n = 3500 > getPointDistance(q[0],c) ? findNereast(jGq,c,7) : findNereast(bjGq,c,5);
        n.forEach(function(c){
            c[0] == l[0][0] && c[1] == l[0][1] || a.push(c)
        });

        async.map(a, function(a,c){
            getRoute(a,c,g)
        }, function(a,c){
            var l = g.map(function(a){
                return a.get.getLength();
            }),
            l = indexOfSmallest(l);
            
        });

    }, center,geoObject);
}

Connected:
<script type="text/javascript" src="https://api-maps.yandex.ru/2.1/?lang=ru_RU"></script>
        <script type="text/javascript" src="map.js"></script>

Gives the following error:
Uncaught ReferenceError: async is not defined
    at map.js:136
    at map.js:102
    at map.js:108
    at ?lang=ru_RU:2
    at s (?lang=ru_RU:2)
    at Array.<anonymous> (?lang=ru_RU:2)
    at n (?lang=ru_RU:2)
    at a (?lang=ru_RU:2)

Browsers: Chrome 59, Opera 46, IE 11
Similar code from mkad.mapcraft.ru works without errors. Third party libraries are not included. How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Luzanov, 2017-08-04
@stcmd04236

A similar code from the site mkad.mapcraft.ru works without errors. Third party libraries are not included.

Yah?
Just the same, this is not a native object, but a self-written one. And if not from any library, then written personally by the developers of the site.
An example of a library from the first lines of Google's issuance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question