我必須做點什麼,我已經有一部分工作。 我想在MySQL數據庫中插入經度(長)和緯度(緯度)。 發現這個代碼誰給我LON和LAT獲取緯度和經度html js
<!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>
此代碼打印長,緯度,我想是讓長,緯度在PHP和後面運行的SQL查詢。
使用'ajax'讓那些COORDS到後端 –
我不知道如何,如果你有一個例子,我可以嘗試做它用ajax.but。 – shmyself
我們不這樣做,但Google會爲您提供無數關於如何將數據發送到服務器的示例。 –