Re: I can't have the return-value from my showAddress
On Dec 14, 5:46 pm, Pileggi <marco_mig...@libero.it> wrote:
> Hi!
> Javascript, Ajax and GMaps all all new things for me.
> I call the function showAddress from a Win-Form with a WebBrowser
> inside, to get the coordinates of an address. But I can't have the
> return-value of the function (I don't know why). Can you (please) give
> me a little code-example?
>
> It returns always "iniziale" (the initial value)
To analyse the problem, take out the callback function. The callback
function is executed separately, when the geocoder results are
returned.
So your code currently does this:
function showAddress(address) {
var map = new GMap2(document.getElementById("map_canvas"));
var geocoder = new GClientGeocoder();
var risultato = "iniziale";
geocoder.getLatLng(address, ... ); // sends off the request
return risultato;
}
At some point the geocoder gets its result and runs the callback
function, but by that stage your showAddress function has already
returned its risultato variable.
Everything you need to do with the geocoder's result must be within
the callback function.
Andrew
--
You received this message because you are subscribed to the Google Groups "Google Maps API" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home