I need to processing list of data via HERE Map geocoder, for convert locationId to coordinates. geocoder class has geocode function that take 3 arguments 1 parameter 2. successCallFunction 3. failCallFunction.
  self.geocodeByLocationIdByArray = function (locationIds, callback)
            {
                var deferred = $.Deferred();
                var result = []; 
                var convert = function () {
                    for (var i = 0; i < locationIds.length - 1; i++)
                    {
                        geocodingParameters = {
                            locationId: locationIds[i].locationId;
                        };
                        self.geocoder.geocoder(geocodingParameters, onGeocodeSuccess, function () { });
                    }
                };
                convert();
                return deferred.promise();
            };
 onGeocodeSuccess = function (result) {
                var locations = result.Response.View[0].Result,
                    i;
                var result = [];
                // Add a marker for each location found
                for (i = 0; i < locations.length; i++) {
                    result.push(new geoCoordinate(locations[i].Location.DisplayPosition.Latitude, locations[i].Location.DisplayPosition.Longitude));
                }
                return result;
            };
How to fix geocodeByLocationIdByArray function for wait until all data is preceded and return result array ? I am a little bit stop on it :( my problem is that geocoder is async.
 
    