제발 ip에 따라 cityname을 찾는 데 도움이됩니다. 설명하겠습니다.Google지도에서 IP로 도시 이름을 얻는 방법은 무엇입니까?
내가 열어 놓은 도시 이름을 자동으로 가져오고 자동으로 Google지도에 위치를 표시해야하는 웹 페이지를 개발 중입니다.
당신은 다음과 같은 위치 API에 대한 IP를 사용한다제발 ip에 따라 cityname을 찾는 데 도움이됩니다. 설명하겠습니다.Google지도에서 IP로 도시 이름을 얻는 방법은 무엇입니까?
내가 열어 놓은 도시 이름을 자동으로 가져오고 자동으로 Google지도에 위치를 표시해야하는 웹 페이지를 개발 중입니다.
당신은 다음과 같은 위치 API에 대한 IP를 사용한다:
http://ipinfodb.com/ip_location_api_json.php
http://www.ipaddressapi.com/ ($)
또는 것은 같은 다른 소스에서 데이터를 얻을 관리 :
을다른 소스는 다음과 같습니다. 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>
언급 할 가치가 또 다른 하나 http://www.maxmind.com/app/ip-location (무료 버전은 있지만 유료 버전 만 도시가 있습니다.) 정확하다면 정확함) – Corbin
이 방법은 끔찍하게 부정확 할 수도 있습니다. 당신이 말할 수있는 가장 가까운 곳은 "영국"입니다. –