2
A
回答
5
您應該使用IP來定位API,像這樣的:
http://ipinfodb.com/ip_location_api_json.php
http://www.ipaddressapi.com/($)
或管理得到像其他來源的數據:
0
另一個來源是:https://www.geoip-db.com它們提供JSON和JSONP回調解決方案。
甲jQuery的例子:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Geo City Locator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body >
<div>Country: <span id="country"></span></div>
<div>State: <span id="state"></spa></div>
<div>City: <span id="city"></span></div>
<div>Latitude: <span id="latitude"></span></div>
<div>Longitude: <span id="longitude"></span></div>
<div>IP: <span id="ip"></span></div>
<script>
$.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?').done(function(location) {
$('#country').html(location.country_name);
$('#state').html(location.state);
$('#city').html(location.city);
$('#latitude').html(location.latitude);
$('#longitude').html(location.longitude);
$('#ip').html(location.IPv4);
});
</script>
相關問題
- 1. 谷歌地圖獲取有城市名稱的經緯度?
- 2. 獲取城市名稱谷歌地圖路線經歷
- 3. 根據城市名稱獲取座標谷歌地圖
- 4. 如何從離子2中的谷歌地圖獲取城市名稱
- 5. 如何執行谷歌地圖搜索街道名稱,城市?
- 6. 如何根據java中的IP地址獲取城市名稱?
- 7. 通過商業名稱在谷歌地圖上獲取標記
- 8. 如何獲得一個城市的緯度,谷歌地圖上的替代API只有城市的名稱
- 9. 地理與城市名稱,谷歌地圖編碼
- 10. 如何通過谷歌API獲取城市結果?
- 11. 從谷歌地圖獲取城市州地圖
- 12. 通過視圖從谷歌地圖獲取元素(國家,城市等)
- 13. 通過正則表達式從地址獲取城市名稱
- 14. 谷歌地圖 - 按城市名稱插入標記
- 15. 獲得來自谷歌地圖的所有城市的名字 - 通過縣
- 16. 如何通過Facebook的城市ID查找城市名稱?
- 17. 如何在谷歌地圖上標記一個城市
- 18. 從郵政編碼獲取城市名稱谷歌地理編碼
- 19. 如何獲得谷歌地圖中的城市GLatLngBounds
- 20. 如何在iphone中獲取地理位置城市名稱?
- 21. 谷歌地圖api城市或郵編
- 22. 與Rails3中+谷歌地圖獲取用戶城市
- 23. 從IP地址獲取城市
- 24. 通過谷歌地圖api獲取城鎮座標php
- 25. 如何在工具欄上獲取當前城市名稱?
- 26. 谷歌地圖獲得城市界限,繪製城市多邊形
- 27. 谷歌地圖(反向)地理編碼API應該只顯示城市名稱
- 28. 如何通過SPARQL名稱獲得城市人口
- 29. Swift通過名稱獲取城市座標
- 30. 如何從街道名稱,地名或城市名稱獲取GPS座標
另外一個值得一提:http://www.maxmind.com/app/ip-location(免費版存在,但只有付費版纔有城市精度,如果我沒有記錯的話) – Corbin 2012-03-20 08:54:34
也值得說這種方法可能是非常不準確的。你可以對我說的最接近「英國」,當然不是地區級的,更不用說城鎮了。 – 2012-03-20 12:23:49