blob: 4fb4a4747b4c99eeed8f674517d2f69fc48bf7b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* eslint-disable no-unsanitized/property */
function success(position) {
let message = document.getElementById("status");
message.innerHTML =
"<img src='http://maps.google.com/maps/api/staticmap?center=" +
position.coords.latitude +
"," +
position.coords.longitude +
"&size=300x200&maptype=roadmap&zoom=12&&markers=size:mid|color:red|" +
position.coords.latitude +
"," +
position.coords.longitude +
"&sensor=false' />";
message.innerHTML += "<p>Longitude: " + position.coords.longitude + "</p>";
message.innerHTML += "<p>Latitude: " + position.coords.latitude + "</p>";
message.innerHTML += "<p>Altitude: " + position.coords.altitude + "</p>";
}
function error(msg) {
let message = document.getElementById("status");
message.innerHTML = "Failed to get geolocation.";
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error("Geolocation is not supported.");
}
|