开发者

Get location of visitor, using GPS if available?

开发者 https://www.devze.com 2022-12-19 05:27 出处:网络
I\'m making a website and I want to sort some search results by distance from the user. I suspect many of my users will want to access my site \"on the road\" due to the nature of my site, with their

I'm making a website and I want to sort some search results by distance from the user. I suspect many of my users will want to access my site "on the road" due to the nature of my site, with their iPhones, BlackBerries, or wha开发者_高级运维t have you. Some of these devices might have GPS's, which I assume is more accurate than an IP-address lookup. Is there a way I can take advantage of this? Even if the user has to click some sort of "Authorize xyz.com to access my location info" I don't think they'll mind too much. I want to fallback on IP-lookup if it's not available.

Can anyone recommend services for this? Interested in free services for testing, paid if it provides significantly better results.

Will be using ColdFusion for this project, if relevant, although I suspect it'll be a REST service so it doesn't really matter.


You could use the geolocation API which is supported by some (not all) browsers. Here's an article describing how it works in Firefox 3.5+.

Here's a question which covers support of the API in various devices.

Google Gears also has a geolocation API.

And here's a library which attempts to unify the different APIs available.

0

精彩评论

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

关注公众号