
Steve - 2013-12-17 14:04:34 -
In reply to message 1 from Steve
I updated this function and have this working again with V3 of the google API. You still must also include your API Key still just need to get a new ver 3 key.
distanceclass.php
[code]
function getCoords(&$location){
$loc = urlencode($location);
$url = "https://maps.googleapis.com/maps/api/geocode/json?address=$loc&sensor=false";
$json_result = json_decode(file_get_contents($url));
$geo_result = $json_result->results[0];
$citya = $geo_result->formatted_address;
$aCsv = $geo_result->geometry->location;
$aCsv = (array) ($aCsv);
$latitude = $aCsv['lat'];
$longitude = $aCsv['lng'];
if(isset($aCsv)) {
return array('lat'=>(float)$aCsv['lat'], 'lng'=>(float)$aCsv['lng'],);
}
return NULL;
}
[/code]