GoogleGeoCoder
-
Hey FS,
I spotted some differences between some previous code and current code on Github as it relates to the GoogleGeoCoder in the common_functions.php.
Can you explain the differences for why you updated the following lines of code:
function google_geocoder($address, $api) {
$address = str_replace(‘ ‘, ‘+’, $address);
$XMLUrl = ‘https://maps.google.com/maps/geo?q=’.$address.’&key=’.$api.’&sensor=false&output=xml&oe=utf8′;$XMLContents = file_get_contents($XMLUrl);
$XML = new SimpleXMLElement($XMLContents);
$Coords = explode(‘,’,$XML->Response->Placemark->Point->coordinates);
return $Coords;
}and the current code:
function google_geocoder($address, $api) {
$Coords = ”;
$address = str_replace(‘ ‘, ‘+’, $address);
$XMLUrl = ‘https://maps.googleapis.com/maps/api/geocode/xml?address=’.$address.’&sensor=false’;
$XMLContents = file_get_contents($XMLUrl);
$XML = new SimpleXMLElement($XMLContents);
if (isset($XML->result->geometry->location->lat)) { $Coords[1] = $XML->result->geometry->location->lat; }
if (isset($XML->result->geometry->location->lng)) { $Coords[0] = $XML->result->geometry->location->lng; }
return $Coords;
}And could there be issues with the older code?
Thanks.
- The topic ‘GoogleGeoCoder’ is closed to new replies.