eXorithm – Execute Algorithm: View / Run Algorithm show_address

Logo Beta

function show_address ($address
{
  $data = file_get_contents"http://maps.googleapis.com/maps/api/geocode/json?address="urlencode$address)."&sensor=false");
  $obj = json_decode$data);
  if ($obj) {
    if (isset$obj->results[0]->geometry->location)) {
      $loc = $obj->results[0]->geometry->location;
      return array'latitude'=>$loc->lat, 'longitude'=>$loc->lng);
    } else {
      throw new Exception'Lookup failed and/or address does not exist!');
    }
  } else {
    throw new Exception'Lookup failed and/or address does not exist!');
  }