geo = function(options){
geocoder.geocode(options, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var x = results;
alert('pear');
return x;
} else {
return -1;
}
});
}
getAddr = function(addr){
if(typeof addr != 'undefined' && addr != null) {
var blah = geo({ address: addr, });
alert('apple');
return blah;
}
return -1;
}
Tak więc, gdy wywołuję getAddr, uzyskuję niezdefiniowane, również jabłko jest ostrzeżone, a następnie gruszka. Zdaję sobie sprawę, że Google mapuje asynchronicznie geokody, ale czy istnieje sposób, aby to zadziałało?Oczekiwanie na geokodera map Google?
Świetny przykład, dziękuję! – g33kz0r