Having problems getting the different arrays content from geocoder results.
item.formatted_address works but not item.address_components.locality?
ge
I think it is a real pain that google doesn't provide some sort of functionality to get these. Anyhow I think the best way of finding the right object is:
geocoder.geocode({'address': request.term }, function(results, status){
response($.map(results, function(item){
var city = $.grep(item.address_components, function(x){
return $.inArray('locality', x.types) != -1;
})[0].short_name;
alert(city);
}
});