Código Javascript:
Ver original
$(document).ready(function() { $("#busprin").keypress(function(e) { if(e.keyCode == 13) { $.ajax({ async: true, url: "http://maps.google.es/maps/geo?output=json&sensor=true&q=" + $("#busprin").val(), dataType:"json", success: function(data){ var json = data; alert(json.name); }, error:function(data){ alert('Error'); } }); }}); });
Código json:
Ver original
{ "name": "ourense", "Status": { "code": 200, "request": "geocode" }, "Placemark": [ { "id": "p1", "address": "Ourense, España", "AddressDetails": { "Accuracy" : 4, "Country" : { "AdministrativeArea" : { "AdministrativeAreaName" : "Galicia", "SubAdministrativeArea" : { "Locality" : { "LocalityName" : "Ourense" }, "SubAdministrativeAreaName" : "Orense" } }, "CountryName" : "España", "CountryNameCode" : "ES" } }, "ExtendedData": { "LatLonBox": { "north": 42.3983214, "south": 42.2881793, "east": -7.8059585, "west": -8.0037342 } }, "Point": { "coordinates": [ -7.8646408, 42.3400086, 0 ] } } ] }