Hello,
I want To convert an address to geographic coordinates with the Google
Maps Geocoding service,
I try to run the script Google Map with the function "function
get_coordonees_from_adresse"
The problem is at line 7: file_get_contents ($url);
I have a message that file_get_contents is not defined,
Someone can help me? Is there a library to include, and if yes, how to
do?
Thank you very much
<code>
function get_coordonees_from_adresse($adresse)
{
$adresse = '5 place Sacré Cœur 12000 RODEZ';
$googlekey = 'ABQIAAAAkmj2n9u-
yh0eajXY2ODfvRTZ-8DaNmJqQ4DZiHMEn4zyFwB_uRS5k_pWD1NMCv_ztgTVW2VD6fFXLA';
$url = 'http://maps.google.com/maps/geo?q=
$adresse&output=xml&oe=utf8&gl=fr&sensor=false&key=&googlekey';
$page = file_get_contents($url);
// Parse le résultat XML
$xml_result = new SimpleXMLElement($page);
// Vérifie que la requête a réussi
if ($xml_result->Response->Status->code != 200) return array();
// Charge les adresses
$adresses = array();
foreach ($xml_result->Response->Placemark as $place) {
list($longitude, $latitude, $altitude) = explode(',', $place-
>Point->coordinates);
// Ajoute au tableau
$adresses[] = array('adresse_complete' => utf8_decode($place-
>address),
'latitude' => $latitude,
'longitude' => $longitude);
}
return $adresses;
}
</code>
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.