I have this code:
function getLatLong(address) {
var geocoder = new google.maps.Geocoder();
var result = "";
geocoder.geocode( { 'address': address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
result[lat] = results[0].geometry.location.Pa;
result[lng] = results[0].geometry.location.Qa;
} else {
result = "Unable to find address: " + status;
}
storeResult(result);
});
}
directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
var request = {
origin: new google.maps.LatLng(getLatLong()[0],getLatLong()[1]),
destination: new google.maps.LatLng(59.79530896374892,30.410317182540894),
travelMode: google.maps.DirectionsTravelMode.DRIVING /
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
map = new google.maps.Map(document.getElementById("map"));
directionsDisplay.setMap(map);
How I can return values origin: new google.maps.LatLng() ? Problem callback, how I can save values in global vars? Please Help fix it. Im have no ideas.