开发者

How to match addresses on websites? (regex? library? google maps?)

I would like to match/highlight addresses e.g. (253 West 125th Street New York, NY 10027) on websites via javascript.

Questions:

  • How to match addresses in content? (开发者_StackOverflow社区for as many countries as possible)
  • Do you know any library or class to get an idea?
  • What regex system could work (contains letters, numbers and has between 3 and 15 words)?
  • Should we match it against the Google API to get an idea if it's a valid address?

thank you for any ideas and input! :)


Yahoo! has a location API which can map addresses to geo locations. For complete geographical services provided by Yahoo! visit the below address.

http://developer.yahoo.com/geo/

Yahoo! PlaceFinder™ converts street addresses and place names into geographic coordinates.


Google Maps, Bing! and Nokia Maps (earlier Navteq and Nokia Ovi Maps, now Nokia Maps integrated to Bing!) also provides geocoding APIs which you can use to convert the addresses to real geo locations.

Google Maps API : http://code.google.com/apis/maps/documentation/javascript/services.html

Cheers!!!


Ouch! This is a tough problem. Unfortunately there isn't a regex in the world that can save you. The only real way to do this is by using some kind of address verification service. Yes Google Maps and the various alternatives can generally tell you if an address looks real and perhaps even plot it on a map, but they can't tell you whether or not the address is actually real and can, for example, receive mail.

I guess the bigger business (rather than technical) question in all of this is: why are you collecting the address in the first place? If you're collecting a piece of data wouldn't it be nice to know that it's correct? For example, rather than collecting a credit card number and assuming that it might be correct because it passes a mod 10 checksum, wouldn't you like to know if the credit card is actually good? Or how about a phone number or email? Sure it might pass a regex, but unless the phone/email is attached to a person, then what good does it do?

The same thing goes with addresses. An address that might be real is just as bad as credit card number that passes integrity checks but isn't an issued credit card number. The only way to ensure an address is deliverable is to utilize a 3rd-party address verification web service.

There are a number of providers out there that offer web services that can be interfaced via Javascript. In the interest of full disclosure, I'm the founder of SmartyStreets. We offer a REST-based address verification web service called LiveAddress that can be accessed through Javascript. It can even accept JSONP calls to get around cross-domain requests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜