我需要一个GPS追踪器,该追踪器可以将纬度线和滞后线发送到我的Web应用程序?任何人都知道要使用什么设备以及如何发送数据吗?

问题描述 投票:0回答:1

我使用这里的地图开发了一个Web应用程序,我需要一个可以给我实时位置的跟踪器。

不知道以下详细信息:1.使用哪种类型的GPS追踪器。2.如何将数据从跟踪器获取到我的网页。

任何人都可以给我一个解决方案,谢谢!

javascript gps location tracking
1个回答
0
投票

尝试一下: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>
© www.soinside.com 2019 - 2024. All rights reserved.