Address.php
23 lines
| 1 | <?php |
| 2 | class Address |
| 3 | { |
| 4 | public $street; |
| 5 | public $city; |
| 6 | |
| 7 | public function getGeoCoords() |
| 8 | { |
| 9 | $data = file_get_contents( |
| 10 | 'http://nominatim.openstreetmap.org/search?q=' |
| 11 | . urlencode($this->street) |
| 12 | . ',' . urlencode($this->city) |
| 13 | . '&format=json&addressdetails=1' |
| 14 | ); |
| 15 | $json = json_decode($data); |
| 16 | return array( |
| 17 | 'lat' => $json[0]->lat, |
| 18 | 'lon' => $json[0]->lon |
| 19 | ); |
| 20 | } |
| 21 | } |
| 22 | ?> |
| 23 |