Lately geo-targeting has been pretty popular in technology. By IP, cell tower, GPS, using browser plugins, HTML5?, mobile devices ...
最近,地理定位在技术上非常流行。通过IP,基站,GPS,浏览器插件,HTML5?,移动设备……
Since I'm about to add some geo-targeted features on our site, I wanted to know what's the best approach. Is there some API that uses a mix of all those technologies? Or at least, what API/service would you recommend I use?
由于我打算在我们的网站上添加一些地理定位的功能,我想知道什么是最好的方法。是否有一些API使用所有这些技术的混合?或者至少,您建议我使用什么API/服务?
The service I'm working on doesn't need to be 100% accurate, so I'm OK with geo-IP, but if there's an easy way to do better, why not.
我正在开发的服务不需要百分之百的精确,所以我对geo-IP没有意见,但是如果有更好的方法,为什么不呢?
Technologies used are php, javascript, ajax, java.
所使用的技术有php、javascript、ajax和java。
5 个解决方案
#1
4
Whatever you do please please please don't set the language of your website based on the user's IP, and then make it almost impossible to change unless you know said language and you feel like wasting hours (like ebay and paypal, among others, do). Use the browser's language.
无论你做什么,请不要根据用户的IP设置你网站的语言,然后让它几乎不可能改变,除非你知道你说的语言,你觉得浪费时间(像易趣和贝宝,等等)。使用浏览器的语言。
Not everyone in, let's say, France speaks or wants to speak French.
不是每个人,比方说,法国人说或者想说法语。
I guess it's not very related to your question but i felt the need to rant about this, sorry :)
我猜这和你的问题不太相关,但我觉得有必要对此大声叫嚷,对不起
#2
1
GEO IP is probably the best approach for now.
GEO IP可能是目前最好的方法。
HTML5 looks promising, but it'll be a while before it's widely supported. And even then it requires explicit user approval, which kind of limits the possibilities for using it (for example auto-redirecting to a country specific version of a website)
HTML5看起来很有前途,但要得到广泛支持还需要一段时间。即使这样,它也需要明确的用户批准,这就限制了使用它的可能性(例如,自动重定向到特定国家版本的网站)
#3
1
For a start try the free http://api.hostip.info?ip=x.x.x.x (www.hostip.info for website)
首先试试免费的http://api.hostip.info?ip= x.x.x.x.x (www.hostip.info For website)
It'll give you city and country in a xml structur. I've a small proxy-script writen in PHP on the http-server, which a html page calls with ajax and show the infomation in text and on a Google map using the Google geocoding api. Later on you can easy replace the api.hostip.info with an other api.
它将在xml结构中为您提供城市和国家。我在http-服务器上有一个用PHP编写的小代理脚本,html页面使用ajax调用它,并使用谷歌地理编码api在文本和谷歌映射上显示信息。稍后,您可以轻松地用另一个api替换api.hostip.info。
#4
0
I would use IP address detection by default, and then optionally ask for a more specific location using the Javascript/HTML5 navigator.geolocation
API when present. (For example, in iPhone Safari)
我将在默认情况下使用IP地址检测,然后可以选择使用Javascript/HTML5 navigator请求一个更具体的位置。地理定位API当礼物。(例如,在iPhone Safari中)
Most users are still using devices that don't know the location themselves, so plugins that are available will not get a better location than IP address detection does anyway. (Alternatively, they'll prompt users to manually enter data, which is annoying)
大多数用户仍在使用不知道位置的设备,因此可用的插件将无法获得比IP地址检测更好的位置。(或者,他们会提示用户手动输入数据,这很烦人)
#5
0
Max Mind is good. But if you are looking for a free solution, you may want to consider using the javascript geocoder. Eventually they will support addresses and country, but right now, they only give you a latitude and longitude.
马克斯思想是好的。但是如果您正在寻找一个免费的解决方案,您可能需要考虑使用javascript geocoder。最终他们将支持地址和国家,但是现在,他们只给你一个纬度和经度。
#1
4
Whatever you do please please please don't set the language of your website based on the user's IP, and then make it almost impossible to change unless you know said language and you feel like wasting hours (like ebay and paypal, among others, do). Use the browser's language.
无论你做什么,请不要根据用户的IP设置你网站的语言,然后让它几乎不可能改变,除非你知道你说的语言,你觉得浪费时间(像易趣和贝宝,等等)。使用浏览器的语言。
Not everyone in, let's say, France speaks or wants to speak French.
不是每个人,比方说,法国人说或者想说法语。
I guess it's not very related to your question but i felt the need to rant about this, sorry :)
我猜这和你的问题不太相关,但我觉得有必要对此大声叫嚷,对不起
#2
1
GEO IP is probably the best approach for now.
GEO IP可能是目前最好的方法。
HTML5 looks promising, but it'll be a while before it's widely supported. And even then it requires explicit user approval, which kind of limits the possibilities for using it (for example auto-redirecting to a country specific version of a website)
HTML5看起来很有前途,但要得到广泛支持还需要一段时间。即使这样,它也需要明确的用户批准,这就限制了使用它的可能性(例如,自动重定向到特定国家版本的网站)
#3
1
For a start try the free http://api.hostip.info?ip=x.x.x.x (www.hostip.info for website)
首先试试免费的http://api.hostip.info?ip= x.x.x.x.x (www.hostip.info For website)
It'll give you city and country in a xml structur. I've a small proxy-script writen in PHP on the http-server, which a html page calls with ajax and show the infomation in text and on a Google map using the Google geocoding api. Later on you can easy replace the api.hostip.info with an other api.
它将在xml结构中为您提供城市和国家。我在http-服务器上有一个用PHP编写的小代理脚本,html页面使用ajax调用它,并使用谷歌地理编码api在文本和谷歌映射上显示信息。稍后,您可以轻松地用另一个api替换api.hostip.info。
#4
0
I would use IP address detection by default, and then optionally ask for a more specific location using the Javascript/HTML5 navigator.geolocation
API when present. (For example, in iPhone Safari)
我将在默认情况下使用IP地址检测,然后可以选择使用Javascript/HTML5 navigator请求一个更具体的位置。地理定位API当礼物。(例如,在iPhone Safari中)
Most users are still using devices that don't know the location themselves, so plugins that are available will not get a better location than IP address detection does anyway. (Alternatively, they'll prompt users to manually enter data, which is annoying)
大多数用户仍在使用不知道位置的设备,因此可用的插件将无法获得比IP地址检测更好的位置。(或者,他们会提示用户手动输入数据,这很烦人)
#5
0
Max Mind is good. But if you are looking for a free solution, you may want to consider using the javascript geocoder. Eventually they will support addresses and country, but right now, they only give you a latitude and longitude.
马克斯思想是好的。但是如果您正在寻找一个免费的解决方案,您可能需要考虑使用javascript geocoder。最终他们将支持地址和国家,但是现在,他们只给你一个纬度和经度。