A set of if statements for every possible type of reply that can be
returned might be unwieldy.

I suggest crawling through the Placemark structure, in the same way that
you would crawl the DOM. E.g. if you want to find the LocalityName, it
might exist but be attached to a higher level element if a level like
AdministrativeArea or SubAdministrativeArea is not present.

Code like this will find "Vancouver" and "Johor Bahru" in those example
locations, and works with any other Placemark layout that contains a
LocalityName.

      function crawl(r,a) {
        if (typeof r[a] == "string"  || typeof r[a] == "number") {
          if (a == "LocalityName") {
            // === Yes, we've found the LocalityName ===
            alert(a + ":" + r[a]);
          }
        } else {
          for (b in r[a]) {
            crawl(r[a],b);
          }
        }
        return output;
      }

...

      for (a in result.Placemark[i]) {
        crawl(result.Placemark[i],a);
      }

-- 
Mike Williams

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-api?hl=en.

Reply via email to