On May 20, 7:41 am, Daniel <[email protected]> wrote:
> I have been reading posts and posts learning jQuery and GoogleMaps API
> to develop ubidnship.com (hopefully going live in the next few days
> but right now redirects to my company's website, which I don't know if
> that's good practice or not!). Now, I am finally brave enough to
> share some code with everyone that I think may be helpful.
>
> I have been searching for a way solve the state abbreviations issue
> because i have filters that require two letter state codes. Here is
> my attempt at a solution that I would like to share with everyone.
So far, Google has either returned a two-word name ("Rhode Island") or
the two-letter abbreviation ("AK"). The two-letter abbreviation has
had dots in it in the past ("A.K."). The geocoder hasn't returned a
single-word name like "Alaska" yet.
One solution which has been suggested in the past, based on this past
performance, is
stateAbbreviation = stateAbbreviation.replace(/[^A-Z]/g,'');
which would alter results like
"Rhode Island" to RI
"South Dakota" to SD
"New York" to NY
"A.K." to AK
while leaving a result like "WA" unaltered. That single line could
certainly replace your "splitting" code.
Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---