/**
  * Autocomplete the location
  *
  *
  * @param string $location
  *
  * @return string the response of a request to google
  */
 public function autocomplete($location)
 {
     $url = $this->baseUrl . '&input=' . urlencode($location);
     $response = $this->scraper->scrape($url);
     $response = json_decode($response);
     if ($response->status != 'OK') {
         return $location;
     }
     return $response->predictions[0]->description;
 }
コード例 #2
0
 /**
  * Returns address from a coordinates
  *
  * @param float $lat
  * @param float $lang
  * @param bool $raw
  *
  * @return string|null
  */
 public function reverseGeocodeAddress($lat, $lang, $raw = false)
 {
     $response = $this->scraper->scrape($this->baseUrl . '&latlng=' . $lat . ',' . $lang);
     $response = json_decode($response);
     if ($response->status != 'OK') {
         $this->handleError($response);
     }
     if ($raw) {
         return $response->results;
     }
     return $response->results[0]->formatted_address;
 }