从浏览器获取客户端位置的方法? [英] Ways to get location of the client from the browser?

查看:18
本文介绍了从浏览器获取客户端位置的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是客户端的纬度/经度(通过浏览器)

What i need is the lat/long of the client(via browser)

在网上找到一些文章,在堆栈溢出本身中找到一些(旧文章)从网络浏览器获取 GPS 位置.差不多 18 个月前就已经回答了这个问题——想知道是否有其他(更有效的)方法可以从浏览器中获取用户位置信息.

Found some articles on the net,found some in stack overflow itself(an old article) Get GPS location from the web browser. it was answered almost 18months ago -- wondering if there's any other(more efficient) way of getting the information of the location of the user from the browser.

到目前为止,找到了 2 个

Soo far,found 2

使用 Maxmind

其他,使用google的api

Other,using google's api

w3c 的 geo api 会有向下兼容性问题:http://dev.w3.org/geo/api/spec-source.html ,所以不要选择那个.

w3c's geo api will have downward compatibility issues: http://dev.w3.org/geo/api/spec-source.html ,so not choosing that.

找到一个站点,www.drumaroo.com -- 请求第一次共享位置当我们进入网站时.需要类似的东西

Found a site, www.drumaroo.com -- requests for the location to be shared the 1st time when we drop into the site.Needed something similar

推荐答案

可以通过以下方式定位用户:-

The user can be located by using following ways:-

  1. 使用 IP 地址.由于网络地址的不确定性,最容易实现但最不可靠/拓扑.
  2. 使用纬度、经度对最准确的解决方案,但大多数最终用户不知道他们的纬度,经度值.
  3. 使用邮政编码很好想,但很难实现,虽然 ZipCodes 被用于
    很长一段时间,但这还不是标准.(见链接
    http://en.wikipedia.org/wiki/Postal_code ).仅邮政编码是不够的计算距离我们需要将其转换为纬度、经度对,这是一个
    开销.
  4. 使用用户的地址最引人注目的想法,因为每个用户都至少有一个地理地址.仅地址不足以计算距离,我们需要将其转换为纬度、经度对,这是一个开销.
  1. Using the IP addr. easiest to achieve but most unreliable due to the uncertainty of network addresses / topologies.
  2. Using the latitude, longitude pair most accurate solution, but most of the end users don’t know about their latitude, longitude value.
  3. Using the zipcodes nice to think but quite difficult to achieve, although ZipCodes are being used for
    quite a long time but this is not a standard yet. (see link
    http://en.wikipedia.org/wiki/Postal_code ). ZipCode alone is not sufficient for calculation of distance we need to convert it to latitude, longitude pair which is an
    overhead.
  4. Using user’s address most compelling thought since each user will have at least one geographic address. Address alone is not sufficient for calculation of distance we need to convert it to latitude, longitude pair which is an overhead.

最好的选择是同时使用选项 2,3.4,您可以分两步完成:-

The Best option will be to use options 2,3.4 together, You can do that in two steps:-

  1. 先从地址确定纬度、经度.
  2. 然后使用这个 lat, long 值进行进一步处理,即存储在数据库等

有关可用于此的各种选项,请参阅 这个问题

For various options available for this see the answer of this question

这篇关于从浏览器获取客户端位置的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆