1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
function searchAddress(id)
{
var tlatlng1, tlatlng2;
geocoder1.geocode(
{
address: clients[id].adresseDepart
},
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
// clients[id].latlngDepart = results[0].geometry.location ;
tlatlng1 = results[0].geometry.location;
alert(tlatlng1);// ok !
}
else
{
alert('Le géocodage 1 a échoué.');
}
});
geocoder2.geocode(
{
address: clients[id].adresseArrivee
},
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
// clients[id].latlngArrivee = results[0].geometry.location ;
tlatlng2 = results[0].geometry.location;
alert(tlatlng2);// ok !
}
else
{
alert('Le géocodage 2 a échoué.');
}
});
alert(tlatlng1);//undefined
return { coordonneesDepart : tlatlng1, coordonneesArrivee : tlatlng2};
} |
Partager