Last active
October 17, 2015 10:07
-
-
Save bitsmanent/c290b8ab6e7963a36fab to your computer and use it in GitHub Desktop.
Take a string representing a location and returns a formatted political name and coordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function strgeo($target) { | |
| $str = rawurlencode($target); | |
| $uri = "http://maps.googleapis.com/maps/api/geocode/json?address=${target}&sensor=true"; | |
| $d = json_decode(file_get_contents($uri), 1); | |
| $d = (@$d['results'][0]); | |
| if(!$d) | |
| return NULL; | |
| return [ | |
| 'targetf' => $d['formatted_address'], | |
| 'coords' => $d['geometry']['location'], | |
| ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment