reverse() public méthode

{@inheritDoc}
public reverse ( $latitude, $longitude )
Exemple #1
0
 /**
  * usage e.g.
  * ```
  * use \dbsparkleTeam\unispot\formatters\AddressFormatter;
  * use \dbsparkleTeam\unispot\components\Location;
  *
  * Location::getAddress(60.023554,30.2232882,[
  *     'type' => AddressFormatter::TYPE_FULL,
  *     'format' => AddressFormatter::FORMAT_NORMAL
  * ])
  * ```
  * @param float $lat
  * @param float $lng
  * @param array $options
  * @return string
  */
 public static function getAddress($lat, $lng, $options = [])
 {
     $curl = new CurlHttpAdapter();
     $geocoder = new GoogleMaps($curl);
     $addressData = $geocoder->reverse($lat, $lng);
     if (!isset($options['format']) || !in_array($options['format'], [AddressFormatter::FORMAT_NORMAL, AddressFormatter::FORMAT_REVERSED])) {
         $options['format'] = AddressFormatter::FORMAT_NORMAL;
     }
     if (!isset($options['type']) || !in_array($options['type'], [AddressFormatter::TYPE_FULL, AddressFormatter::TYPE_SHORT])) {
         $options['type'] = AddressFormatter::TYPE_FULL;
     }
     return AddressFormatter::format($addressData->first(), $options);
 }
 /**
  * @expectedException \Geocoder\Exception\NoResult
  * @expectedExceptionMessage Could not execute query "http://maps.googleapis.com/maps/api/geocode/json?address=48.863151%2C2.388911".
  */
 public function testReverseWithCoordinatesGetsNullContent()
 {
     $provider = new GoogleMaps($this->getMockAdapterReturns(null));
     $provider->reverse(48.8631507, 2.388911);
 }