Forum Moderators: open

Message Too Old, No Replies

Returning from a function which is a argument of a object

where to grab the returned value of a functon which is a argument of a obje

         

bleak26

5:22 pm on Mar 6, 2008 (gmt 0)

10+ Year Member



I am a very newbie at java script and i am attempting to geo code an address. i have a function which is the argument for the geocoder.getLatLng object. I need to get the value returned from the function(point) but i cannot work out where to place the variable in doaddress, which will recieve the newlatandlong variable returned from the function(point).


function doAddress(address) {
if (geocoder) {
var finalgeodetails;

geocoder.getLatLng(address,
[b]function(point)[/b] {
if (!point) {
alert(address + " not found by chris system");
} else {

var newlatandlong = point.lat() + ',' + point.lng();

return newlatandlong;

}
}
);
}
return finalgeodetails;
}

MarkFilipak

6:02 pm on Mar 6, 2008 (gmt 0)

10+ Year Member



I have no idea what geocoder is all about but I think I see what you're trying to do. Try this:

function doAddress(address) {
if (geocoder)
return geocoder.getLatLng (
address,
function(point) {
if (!point) alert(address + " not found by chris system");
else return point.lat() + ',' + point.lng();
}
);
else alert("geocoder not found.");
}