Reputation: 1156
i got this function:
function myfunc()
{
var x;
geo.geocode({ 'latLng': marker.getPosition() }, function (results, status) {
somestuff...
x = what i need;
});
alert(x); //x undefined...
}
The geocoding function is working properly... How can I solve this problem??
Upvotes: 0
Views: 378
Reputation: 32
I think the problem is that you set x
inside a callback function
. You set the callback and after that you call alert()
, but the callback function
might not have been executed at that point.
Upvotes: 1