I'm using a function to return from google matrix api, the distance between two cities.
The problem is that when cities have names similar to those of North American cities, the distance calculation gives an error.
Is there a way to tell the API that the country is Brazil?
Here's the function:
private function calculaDistancia () {
$this->destino = str_replace(" ","%20",$this->phpUtil->limpaCaracters($this->destino));
$url = "http://maps.googleapis.com/maps/api/distancematrix/xml?Key=".$this->key."&origins=''".$this->origem."''|&destinations=''".$this->destino."''|&mode=''".$this->mode."''|&language=''".$this->language."''|&sensor=false
";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
$freteXML = simplexml_load_string($data);
$distancia = $freteXML->row->element->distance->value;
return $distancia;
}
Here's the attempt with the city California-PR
region = br country = br
Nothing works out.