Last active
January 14, 2024 02:11
-
-
Save duyixian1234/ef00e1434ab6ac108ae9fa4ee15d48d2 to your computer and use it in GitHub Desktop.
gps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>GPS Stat</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| </head> | |
| <body> | |
| <div | |
| class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl m-4" | |
| > | |
| <div class="md:flex"> | |
| <div class="p-8"> | |
| <div | |
| class="uppercase tracking-wide text-sm text-indigo-500 font-semibold" | |
| > | |
| GPS状态 | |
| </div> | |
| <p id="longitude" class="mt-2 text-gray-500"> | |
| 经度: <span id="longitude"></span> | |
| </p> | |
| <p id="latitude" class="mt-2 text-gray-500"> | |
| 纬度: <span id="latitude"></span> | |
| </p> | |
| <p id="altitude" class="mt-2 text-gray-500"> | |
| 海拔: <span id="altitude"></span> | |
| </p> | |
| <p id="device-angle" class="mt-2 text-gray-500"> | |
| 设备倾角: <span id="device-angle"></span> | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| function getGPS() { | |
| navigator.geolocation.getCurrentPosition( | |
| function (position) { | |
| document.getElementById("longitude").innerHTML = | |
| position.coords.longitude; | |
| document.getElementById("latitude").innerHTML = | |
| position.coords.latitude; | |
| document.getElementById("altitude").innerHTML = | |
| position.coords.altitude; | |
| document.getElementById("device-angle").innerHTML = | |
| position.coords.heading; | |
| }, | |
| function (error) { | |
| console.log(error); | |
| } | |
| ); | |
| } | |
| setInterval(getGPS, 1000); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment