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無關PHP – Andreas
我在這裏沒有看到任何與PHP相關的任何內容,因此移除標籤。還清理了格式和語法。 – Sid