hola hace un tiempo me funcionaba perfecto este codigo y no entiendo lo que paso.
codigo:
<?php
$calle="Hermanos Amunategui"; //$Container->calle->GetValue(true);
$numero="980"; //$Container->numero->GetValue(true);
$comuna="santiago";
$address =$calle." ".$numero.", $comuna".",chile"; // 'santo domingo 916,santiago,chile';
echo $address."<br>";
$direccion="http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=$region" ;
echo "<br>".$direccion;
$address = str_replace(" ", "+", $address);
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=$region" );
$json = json_decode($json);
$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$lo = $json->{'results'}[1]->{'geometry'}->{'location'}->{'lng'};
echo $lat;
echo "<br>**$lo";
?>
Los echos salen en blanco.
pero si llamo directo :
http://maps.google.com/maps/api/geoc...dress=Hermanos Amunategui 980, santiago,chile&sensor=false®ion=
Me devuelve un resultado.
{
"results" : [
{
"address_components" : [
{
"long_name" : "980",
"short_name" : "980",
"types" : [ "street_number" ]
},
{
"long_name" : "Hermanos Amunátegui",
"short_name" : "Hermanos Amunátegui",
"types" : [ "route" ]
},
{
"long_name" : "Santiago",
"short_name" : "Santiago",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santiago",
"short_name" : "Santiago",
"types" : [ "administrative_area_level_3", "political" ]
},
{
"long_name" : "Santiago",
"short_name" : "Santiago",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Región Metropolitana",
"short_name" : "Región Metropolitana",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Chile",
"short_name" : "CL",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Hermanos Amunátegui 980, Santiago, Región Metropolitana, Chile",
"geometry" : {
"location" : {
"lat" : -33.4327897,
"lng" : -70.6575953
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : -33.4314407197085,
"lng" : -70.65624631970849
},
"southwest" : {
"lat" : -33.4341386802915,
"lng" : -70.65894428029149
}
}
},
"place_id" : "ChIJ5WrbnLDFYpYRBv_yyDSe7NY",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
Espero alguien me pueda orientar.
saludos