Your English is fine, no worries there. :-) But I'm not sure exactly what you want to do.
This can't work: results[0].address_components.long_name.types.country.political because address_components is an array. The array does not have a property called long_name. Each *element* of the array has a long_name property. You get to the individual elements with the [n] notation. [n] doesn't have to be a number constant. It can be a variable containing a number. Do you want to access each of the array elements, one by one? Then you can write a loop to do that. But before I speculate and give code samples that may not be relevant, how about describing in more detail what you want to do with the address_components array? -Mike On Thu, Mar 31, 2011 at 6:35 PM, edgardo.garza <[email protected]>wrote: > hello, it´s my first message, and i really need help i just dont know > how to acces data from the JSON archive that generates the geocoder > API for example this: > > { > "status": "OK", > "results": [ { > "types": [ "locality", "political" ], > "formatted_address": "Washington D. C., Distrito de Columbia, > EEUU", > "address_components": [ { > "long_name": "Washington D. C.", > "short_name": "Washington D. C.", > "types": [ "locality", "political" ] > }, { > "long_name": "Distrito de Columbia", > "short_name": "DC", > "types": [ "administrative_area_level_1", "political" ] > }, { > "long_name": "Estados Unidos", > "short_name": "US", > "types": [ "country", "political" ] > } ], > > > ok, i can acces using this: > > document.getElementById('name').value = > results[0].address_components[3].long_name; > > and it shows, "Estados Unidos". > > but I want to access it this way: > > results[0].address_components.long_name.types.country.political > > i know this is incorrect, but i wanna acces to the data without using > a number in "address_components[x]" > > > thanks. > > BTW sorry for my english > > > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps JavaScript API v3" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
