Google Blogoscoped

Forum

Latitude Longitude on Google Maps?

Philipp Lenssen [PersonRank 10]

Monday, July 4, 2005
15 years ago

Does anyone know how I can get the latitude/ longitude values for a place I searched on on Google Maps?

Pierre S [PersonRank 10]

15 years ago #

just click on link this page and grab the first two values in the url.These are your coords.

Suramya Tomar [PersonRank 1]

15 years ago #

Try using the following code (written in PHP).

function get_lat_long($q) {
   $gm = fopen(' maps.google.com/maps?q=' .rawurlencode(str_replace('','+',$q)) . '&output=js','r');
   $tmp = @fread($gm,30000);
   fclose($gm);
   $x = preg_replace ('/.*<point lat="([^"]*)" lng="([^"]*)".*/',
"|$1|$2|", nl2br(trim($tmp)));
   list ($dmy,$lat_value, $lng_value) = explode ("|",$x);
   return(array('latitude'=>$lat_value,'longitude'=>$lng_value));
}

and then call it using:

$tmp = get_lat_long($address_string);

Where the address string is the address you searched for. Hope this helps.

- Suramya

This thread is locked as it's old... but you can create a new thread in the forum. 

Forum home

Advertisement

 
Blog  |  Forum     more >> Archive | Feed | Google's blogs | About
Advertisement

 

This site unofficially covers Google™ and more with some rights reserved. Join our forum!