<?php
// Clean the address just in case function cleanAddress($address){ return str_replace("'", '', utf8_encode(str_replace("\n", '', $address))); }
// Make a nice search string $searchString = rawurlencode(cleanAddress($myAddress));
// The location of the google maps geocoder $address = "http://maps.google.com/maps/geo?q=".$searchString."&output=xml&key=$myGoogleKey";
// Get the xml code $page = file_get_contents($address);
if($page){
list($junk, $page) = split('<coordinates>', $page);
list($page, $junk) = split('</coordinates>', $page);
list($longitude, $latitude, $altitude) = split(',', $page); echo 'lon: '.$longitude.' lat: '.$latitude;
}
?>
<?php // Clean the address just in case function cleanAddress($address){ return str_replace("'", '', utf8_encode(str_replace("\n", '', $address))); } // Make a nice search string $searchString = rawurlencode(cleanAddress($myAddress)); // The location of the google maps geocoder $address = "http://maps.google.com/maps/geo?q=".$searchString."&output=xml&key=$myGoogleKey"; // Get the xml code $page = file_get_contents($address); if($page){ list($junk, $page) = split('<coordinates>', $page); list($page, $junk) = split('</coordinates>', $page); list($longitude, $latitude, $altitude) = split(',', $page); echo 'lon: '.$longitude.' lat: '.$latitude; } ?>
|