0

I want to get the var lat and lng out of the function, to use it in var bounds later. Is the use of the return statement correct? The code at the bottom does not change the var bounds for some reason.

Still do not get it to work. I am really sorry for wasting your time...

function foo(bounds){
if(bounds = "((1,180), (-1,-180))"){
    bounds ="";
    var address = "<?php echo $_GET['SuchePlz']; ?>";
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({address: address}, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var lat =results[0].geometry.location.lat();
            var lng =results[0].geometry.location.lng();
            bounds = lat;

        } 
        else {
         alert(address + ' not found');
        }
     return bounds;
    });

       }
else{"";}
}

       bounds = foo();
Steakic
  • 1
  • 2

0 Answers0