I have an encoded XML-file, which contains multiple rides. I want to use reverse geocoding for retrieving the actual locations. But when I upload the XML file, I get different locations when I refresh the page. It seems to be the cache, because there are a lot locations, which are the same as the ones above.
//Get Location Start
//Get location
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=".$locBegLat.",".$locBegLon."&sensor=false";
$data = @file_get_contents($url);
$jsondata = json_decode($data,true);
if(is_array($jsondata) && $jsondata['status'] == "OK"){
//street
foreach ($jsondata["results"] as $result) {
foreach ($result["address_components"] as $address) {
if (in_array("route", $address["types"])) {
$streetBeg = $address["long_name"];
}
}
}
//street_number
foreach ($jsondata["results"] as $result) {
foreach ($result["address_components"] as $address) {
if (in_array("street_number", $address["types"])) {
$street_numberBeg = $address["long_name"];
}
}
}
// city
foreach ($jsondata["results"] as $result) {
foreach ($result["address_components"] as $address) {
if (in_array("locality", $address["types"])) {
$cityBeg = $address["long_name"];
}
}
}
// postal_code
foreach ($jsondata["results"] as $result) {
foreach ($result["address_components"] as $address) {
if (in_array("postal_code", $address["types"])) {
$postal_codeBeg = $address["long_name"];
}
}
}
// country
foreach ($jsondata["results"] as $result) {
foreach ($result["address_components"] as $address) {
if (in_array("country", $address["types"])) {
$countryBeg = $address["long_name"];
}
}
}
}
$LocBeg = $streetBeg . " " . $street_numberBeg;
echo $streetBeg;
echo $street_numberBeg;
echo $cityBeg;
echo $countryBeg;
echo $postal_codeBeg;
the website is: www.interwebmedia.nl/dataxi
xml file: https://drive.google.com/file/d/0B31rNYjTJf81dkQ4R2xOcUc2WEk/edit?usp=sharing
I hope someone knows, why the locations are different using the same coordinates, just by refreshing the page after uploading the file.