Obteniendo coordenadas gmaps

http://maps.google.com/maps/geo?q=08024+es&output=csv&key=[KEY GOOGLE MAPS]

Esta url te devuelve lo siguiente:

200,5,51.494937,-0.164561

  • 200 = estado
  • 5 = acc
  • 51.494937 = Latitud
  • -0.164561 = Longitud

Para coger-lo podriamos montar una función como esta:


function getGeo ($postalcode, $keygmaps){

$whereurl = str_replace(' ','%20',$postalcode) . '+es';
$gmapsURL = 'http://maps.google.com/maps/geo?q='.$whereurl.'&output=csv&key='.$keygooglemaps;
$location = file($gmapsURL);
$res = explode(',',$location[0]);
return $res;

}

blog comments powered by Disqus
 
Google Analytics Alternative