Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $q=$_GET['message'];
- function getLatLong($address){
- if (!is_string($address)) die('All Addresses must be passed as a string');
- $_url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address));
- $_result = false;
- if($_result = file_get_contents($_url)) {
- if(strpos($_result,'errortips') > 1 || strpos($_result,'Did you mean:') !== false) return false;
- //print_r($_result);
- preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $_result, $_match);
- $_coords['lat'] = $_match[1];
- $_coords['long'] = $_match[2];
- }
- return $_coords;
- }
- $c=getLatLong($q);
- if(isset($c))
- echo "LAT: ".$c['lat']."<br/>LONG: ".$c['long'];
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement