0
PHP를 사용하여 위도와 경도를 찾고 싶습니다.JavaScript 코드를 사용하여 실제 위도와 경도를 찾는 방법은 무엇입니까?
여러 가지 방법을 시도했지만 솔루션은 서비스 제공 업체 위치 및 IP 주소 만 표시합니다. 나는 나의 진짜 위도와 경도를 찾고 싶다.
아래 코드를 사용하고 있지만 제대로 작동하지 않습니다.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
PHP는 도움이되지 않습니다. 서버 측 언어이기 때문에 어떤 수단으로도 실제 위치를 찾을 수 없습니다. –
PHP와 관련이 없으므로 php 태그를 제거하십시오. – Andreas
PHP 관련 내용이 없습니다. 여기 따라서 태그를 제거하십시오. 또한 서식과 문법을 정리했습니다. – Sid