0
votes

In version 2 of google maps geocoder api there was a method geocoder.getLocations that gave a lot of info about the requested address like : country , street, zip code , lat, lng, etc ...

Seems like the method is gone in v3 and we need to iterate the address_component

when i try to do so i get an error 'j is not defined' when running this

$.each(results[0].address_component, function (index, value) {
                        alert(index + ': ' + value);
                    });

http://maps.googleapis.com/maps/api/geocode/xml?address=75001,france&sensor=false

How do i iterate the adress_component or better yet how to i get to the adress_component->type country -> short name

Thanks

1

1 Answers

0
votes

I found how to iterate the collections

$.each(results[0].address_components, function (index, value) {
                    $.each(value, function (index2, val) {
                        alert(index2 + ': ' + val);
                    });
                });

but is there a faster jquery way to get to a specific item without iterating ? I want to get to address_components of type 'Country' I guess it now a JQuery question