Address component type in google maps geocoding

Posted by user552828 on Stack Overflow See other posts from Stack Overflow or by user552828
Published on 2010-12-23T21:58:44Z Indexed on 2010/12/25 3:54 UTC
Read the original article Hit count: 319

this is a part of my geocoding code. I want it to show only country of the selected place, but it shows all address components, My problem is I cant specify the address components object. There is a way of doing it that is written on documentation but I didnt understand, can you do it for me.

 if (geocoder) {
                geocoder.geocode({'latLng': latlng}, function(results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        var str = "";
                        $.each(results, function(){
                            str += "address components: <ul>"
                            $.each(this.address_components, function(){
                                str +="<li>"+this.types.join(", ")+": "+this.long_name+"</li>";
                            });
                            str +="</ul>";
                        });
                        $("#geocode_info").html(str);

© Stack Overflow or respective owner

Related posts about api

Related posts about google-maps