Need a client side API for determing geo location

2020-01-29 09:10发布

I need a client side API in either Java or Ruby. I would much prefer need this to be LOCAL only. Infact this might not even be an IP, but more of a database import. The thing is that I cannot make use of a web service based one as that is too much heavy I/O for me.

Note: By geolocation, all I really need is country/region at best. I would accept actual lat/long cordinates as well.

3条回答
beautiful°
2楼-- · 2020-01-29 09:46

For a web based one you can use: http://code.google.com/apis/ajaxsearch/. All you do is have:

<script type="text/javascript" src="http://www.google.com/jsapi?key=yourapikey"></script>

and now Google populates some javascript variables and in your other js scripts you can now access geographic location using: google.loader.ClientLocation.address.city, google.loader.ClientLocation.address.region, google.loader.ClientLocation.address.country.

For a very rough and local solution you can get the IP ranges of countries here: http://www.countryipblocks.net/continents/. You can basically store this locally and reference it to get a rough geographic location.

查看更多
叼着烟拽天下
3楼-- · 2020-01-29 09:50

I was looking at these guys a couple months ago: http://www.maxmind.com/app/geolitecountry

It seemed OK, for my limited purposes.

查看更多
爷的心禁止访问
4楼-- · 2020-01-29 09:58

a quick google search yielded this result: http://www.hostip.info/dl/index.html

I think it is what you are looking for.

查看更多
登录 后发表回答