我使用这里的地图开发了一个Web应用程序,我需要一个可以给我实时位置的跟踪器。
不知道以下详细信息:1.使用哪种类型的GPS追踪器。2.如何将数据从跟踪器获取到我的网页。
任何人都可以给我一个解决方案,谢谢!
尝试一下:https://www.w3schools.com/html/html5_geolocation.asp
<!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>