用于位置的 Google API,基于用户 IP 地址 [英] Google API for location, based on user IP address

查看:16
本文介绍了用于位置的 Google API,基于用户 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用 Google Maps API 根据 IP 地址获取用户当前位置(城市)的方法.

I am looking for a way to get the user's current location (city) based on is IP address using the Google Maps APIs.

类似于 http://freegeoip.net/json 但仅使用 Google Maps API.这可能吗?

Something similar to http://freegeoip.net/json but only using the Google Maps APIs. Is this possible?

推荐答案

Google 已经将位置数据附加到进入 GAE 的所有请求中(请参阅 go, javaphppython).您应该对 X-AppEngine-CountryX-AppEngine-RegionX-AppEngine-CityX-AppEngine- 感兴趣CityLatLong 标头.

Google already appends location data to all requests coming into GAE (see Request Header documentation for go, java, php and python). You should be interested X-AppEngine-Country, X-AppEngine-Region, X-AppEngine-City and X-AppEngine-CityLatLong headers.

一个例子如下所示:

X-AppEngine-Country:US
X-AppEngine-Region:ca
X-AppEngine-City:norwalk
X-AppEngine-CityLatLong:33.902237,-118.081733

这篇关于用于位置的 Google API,基于用户 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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