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

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

问题描述

我正在寻找一个APi,它可以根据IP地址返回用户的当前位置(城市)。我搜索了它并找到了



http://freegeoip.net/json



但我的客户是一位谷歌的粉丝,并坚持只为任何可用的谷歌API,有人可以帮我解决这个问题。 解决方案

谷歌已经将位置数据追加到进入GAE的所有请求中(请参阅请求标头文档以了解 java php py马拉松)。您应该感兴趣 X-AppEngine-Country X-AppEngine-Region X- AppEngine-City X-AppEngine-CityLatLong 标题。

一个例子看起来像这个:
$ b $ pre $ code X-AppEngine-Country:
X-AppEngine-Region:ca
X- AppEngine-City:诺瓦克
X-AppEngine-CityLatLong:33.902237,-118.081733


i am looking for an APi which could return back user's current location(city) based on it's IP adress.i searched for it and found

http://freegeoip.net/json

But my client is a big time Google Fan and is insisting only for any available Google API, can some one help me out with this.

解决方案

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.

An example looks like this:

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天全站免登陆