显示位置的最简单方法?

发布于 2024-10-06 19:50:23 字数 221 浏览 0 评论 0原文

什么是最新的、准确的、交钥匙代码注入到页面中以自动读取用户的IP并吐出他们的城市...在这个页面上,我们从gotorain.com借用我希望它显示.. . 距离(动态城市)

http://www.drillavailable.neighborrow.com/以内

What is the most up to date, accurate, turn-key code to inject into a page to automatically read a user's IP and spit out their city... on this page we are borrowing from goingtorain.com I want it to display ... within 3 miles of (dynamic city)

http://www.drillavailable.neighborrow.com/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风追烟花雨 2024-10-13 19:50:23

我们一直在考虑使用的另一个是 http://www.maxmind.com/app/geolitecity。看起来设置相当简单,并且是开源/免费的,具有适用于大多数流行语言的 API。

除了玩了 5 分钟之外没有做太多事情,但看起来很有希望。

Another one we've been looking at to use is http://www.maxmind.com/app/geolitecity. Looks to be fairly simple to setup and is open source/free with apis for most popular languages.

Not done much other than play with it for 5 mins but looks promising.

与往事干杯 2024-10-13 19:50:23

我会选择位置感知浏览。查看 W3C GeoLocation API

例如,尝试 Google Gears 地理定位模块

这些技术使您的客户不仅可以通过查看其 IP(可以有 200 公里偏移)进行地理定位,还可以通过对附近无线接入点的 SSID 信息进行三角测量,而且这可以非常精确。

一旦获得(经度,纬度)坐标,只需调用一些网络服务即可获取最近城市的名称。

I'd go with location aware browsing. Look into the W3C GeoLocation API.

For example, try Google Gears Geolocation module.

These technologies allow your clients to be geolocalized not only by looking and their IP (which can have 200km offsets) but also by triangulating SSID information from nearby wireless Access Points, and this can be extremely precise.

Once you have the (lon,lat) coordinates, it's just a matter of calling some webservice to get the nearest city's name.

静待花开 2024-10-13 19:50:23

我会选择位于 http://ipinfodb.com 的定位器 API 您可以通过 XML 或 JSON 访问它,将您的 API 发送给它密钥和 IP,它将返回城市、州、邮政编码、国家/地区等。然后您可以用您选择的语言解析结果。这是实现此目的的最简单方法,无需实际存储任何有关 IP/位置路由的信息。

I would choose the locator API at http://ipinfodb.com You can access it via XML or JSON, send it your API key and an IP and it will return the city, state, zip, country, etc. You can then parse the results in your language of choice. Its the simplest way to achieve this without actually storing any information about IP/location routing.

零度℉ 2024-10-13 19:50:23

是的,您只需要使用 google.loader 命名空间中的 ClientLocation 对象。整个代码总共是。

<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
  alert(google.loader.ClientLocation.address.city);
} else {
  alert("Not found");
}
</script>

可用的属性有

  • google.loader.ClientLocation.latitude
  • google.loader.ClientLocation.longitude
  • google.loader.ClientLocation.address.city
  • google.loader.ClientLocation.address.country
  • google.loader.ClientLocation.address.country_code
  • google.loader.ClientLocation .地址.区域

Yes, you only need to use the ClientLocation object in the google.loader namespace. In total the whole code is.

<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
  alert(google.loader.ClientLocation.address.city);
} else {
  alert("Not found");
}
</script>

The properties available are

  • google.loader.ClientLocation.latitude
  • google.loader.ClientLocation.longitude
  • google.loader.ClientLocation.address.city
  • google.loader.ClientLocation.address.country
  • google.loader.ClientLocation.address.country_code
  • google.loader.ClientLocation.address.region
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文