Monday, September 17, 2018

javascript - HOW to implement this method with a promise

Answer



How would I use a promise to wait for the asynchronous geocode method to return a result and then return either true or false?



function LocationValidator(value, element, paras) {
var geocoder = new google.maps.Geocoder();

geocoder.geocode({ 'address': value }, function (results, status) { // called asynchronously

if (status == google.maps.GeocoderStatus.OK) {
return true;
} else {
return false;
}
});
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...