Hi all,
need hlp please.
This is the case - function get full URL to Google Maps XML document [with all the parameters of searched address].
This is the code
function getcoordinates($location) {
$mapaddress = urlencode("$location");
// Desired address
$key = MAPS_KEY;
$url = "http://maps.google.com/maps/geo?q=$mapaddress&output=xml&key=$key";
// Retrieve the URL contents
$page = file_get_contents($url);
// Parse the returned XML file
$xml = new SimpleXMLElement($page);
// Parse the coordinate string
list($longitude, $latitude, $altitude) = explode(",", $xml->Point->coordinates);
print '<pre>'; print_r($xml->Point->coordinates); exit('</pre>');
$geo['lat'] = $latitude;
$geo['long'] = $longitude;
$geo['alt'] = $altitude;
return $geo;
}
With this code I get:
Notice: Undefined offset: 2 in ..../functions.php on line 36
Notice: Undefined offset: 1 in ..../functions.php on line 36
Line 36 is:
list($longitude, $latitude, $altitude) = explode(",", $xml->Point->coordinates);
Problem is that I don't get coordinates of searched address.
Please, help.
Thx in advance,
Davor