I guess the documentation about Address Component Types is a bit too subtle as to (not mentioning) the fact that there is no guarantee that the types[]
array will always contain something, or that hese types may also be returned within address_components[]
arrays ... or may not.
Your example reproduces this behavior pretty well:
http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Hopi%20Indian%20Reservation
The types[]
array is empty for the first result and its first address component.
Short term, I think your (and everybody's) code should be ready to accept empty types[]
arrays. Long term, I'd agree it'd be better to give every result at least one type. For the specific case of indian reservations, I've no idea which one (if any) of the available ones would make sense. Maybe one of...
- political indicates a political entity. Usually, this type indicates a polygon of some civil administration.
- colloquial_area indicates a commonly-used alternative name for the entity.
- park indicates a named park.
- point_of_interest indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category such as "Empire State Building" or "Statue of Liberty."
If anyone has a clear idea how to classify these in the available Address Component Types, please file a feature request for the Geocoding API ;)