コード例 #1
0
ファイル: Exception.php プロジェクト: mafiu/listapp
 /**
  * Get the GeoCode error associated with this GeoCode_Exception. This function
  * simply returns the value of {@link GeoCoder::getErrorMessage()} and passes
  * the error code
  *
  * Returns N/A when no driver is set
  *
  * @return string
  */
 public function getGeoCodeMessage()
 {
     // Return the GeoCoder error message associated with this excpetion.
     // If a valid code is not found, it will just return 'Unknown'
     // If no driver is specified, it will just return 'N/A'
     return $this->driver === null ? 'N/A' : $this->driver->getErrorMessage($this->code);
 }
コード例 #2
0
 /**
  * Get the geocode result object from the geocoder object.
  * @param string $apiKey           - google map api key.
  * @param array  $geoCodeQueryData - required query data in the form of array.
  * @return object                  - geocoder result object.
  */
 public static function getGeoCodeResultByData($apiKey, $geoCodeQueryData)
 {
     assert('$apiKey == null || is_string($apiKey)');
     assert('is_array($geoCodeQueryData)');
     Yii::import('application.extensions.geocoder.*');
     $geoCoder = new GeoCoder();
     $geoCoder->setApiKey($apiKey);
     $geoCoder->setApiDriver('Google');
     $geoCoder->init();
     $geoCodeDriver = GeoCode_Driver::factory($geoCoder->getApiDriver(), $apiKey);
     if ($geoCodeQueryData['latitude'] == null && $geoCodeQueryData['longitude'] == null) {
         $geoCodeResult = $geoCoder->query($geoCodeQueryData['query']);
         $geoCodeQueryData['latitude'] = $geoCodeResult->latitude;
         $geoCodeQueryData['longitude'] = $geoCodeResult->longitude;
         return new GeoCode_Result($geoCodeDriver, $geoCodeQueryData);
     } else {
         return new GeoCode_Result($geoCodeDriver, $geoCodeQueryData);
     }
 }
コード例 #3
0
ファイル: GeoCoder.php プロジェクト: mafiu/listapp
 /**
  * Set the driver for the GeoCode requests
  *
  * @param string $driver
  * @return boolean
  */
 public function setDriver($driver)
 {
     // Lowercase for comparisons
     $driver = strtolower($driver);
     // If this driver is the same as the current driver, skip
     if ($this->_driver !== null && $this->api_driver == $driver) {
         return true;
     }
     // Make sure the driver exists
     if (!empty($driver)) {
         // Load the new driver
         $this->_driver = GeoCode_Driver::factory($driver, $this->api_key);
         // Save the driver string
         $this->api_driver = $driver;
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: Result.php プロジェクト: youprofit/Zurmo
 /**
  * Get the string associated with the accuracy constant
  *
  * @return string
  */
 public function getAccuracyString()
 {
     return $this->_driver->getAccuracyString($this->accuracy);
 }