1 | <?php namespace Arcanedev\GeoLocation\Google\Geocoding; |
||
16 | class GeocodingService extends AbstractWebService |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Constants |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | const BASE_URL = 'https://maps.googleapis.com/maps/api/geocode/json'; |
||
24 | |||
25 | /* ----------------------------------------------------------------- |
||
26 | | Constructor |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * GoogleDistanceMatrix constructor. |
||
32 | * |
||
33 | * @param \GuzzleHttp\ClientInterface $client |
||
34 | */ |
||
35 | 9 | public function __construct(ClientInterface $client) |
|
41 | |||
42 | /* ----------------------------------------------------------------- |
||
43 | | Main Methods |
||
44 | | ----------------------------------------------------------------- |
||
45 | */ |
||
46 | |||
47 | /** |
||
48 | * Get the geocoding response. |
||
49 | * |
||
50 | * @param string $address |
||
51 | * @param array $options |
||
52 | * |
||
53 | * @return \Arcanedev\GeoLocation\Google\Geocoding\GeocodingResponse |
||
54 | */ |
||
55 | 3 | public function geocode($address, array $options = []) |
|
65 | |||
66 | /** |
||
67 | * Reverse geocoding (address lookup). |
||
68 | * |
||
69 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $position |
||
70 | * @param array $options |
||
71 | * |
||
72 | * @return \Arcanedev\GeoLocation\Google\Geocoding\GeocodingResponse |
||
73 | */ |
||
74 | 3 | public function reverse(PositionContract $position, array $options = []) |
|
84 | |||
85 | /** |
||
86 | * Reverse geocoding (address lookup & simplified). |
||
87 | * |
||
88 | * @param float $lat |
||
89 | * @param float $long |
||
90 | * @param array $options |
||
91 | * |
||
92 | * @return \Arcanedev\GeoLocation\Google\Geocoding\GeocodingResponse |
||
93 | */ |
||
94 | 3 | public function reversePosition($lat, $long, array $options = []) |
|
98 | |||
99 | /* ----------------------------------------------------------------- |
||
100 | | Other Methods |
||
101 | | ----------------------------------------------------------------- |
||
102 | */ |
||
103 | |||
104 | /** |
||
105 | * Get the default query params. |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | 6 | protected function getDefaultQueryParams() |
|
115 | |||
116 | /** |
||
117 | * Prepare the response. |
||
118 | * |
||
119 | * @param \Psr\Http\Message\ResponseInterface $response |
||
120 | * |
||
121 | * @return \Arcanedev\GeoLocation\Google\Geocoding\GeocodingResponse |
||
122 | */ |
||
123 | 6 | private function prepareResponse($response) |
|
129 | } |
||
130 |