用于位置的 Google API,基于用户 IP 地址 [英] Google API for location, based on user IP address
问题描述
我正在寻找一种使用 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, java、php 和 python).您应该对 X-AppEngine-Country
、X-AppEngine-Region
、X-AppEngine-City
和 X-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屋!