01.
<!DOCTYPE html>
02.
<html>
03.
<head>
04.
<meta charset=
"utf-8"
/>
05.
<title>ทดสอบ geolocation</title>
07.
</head>
08.
<body>
09.
ตำแหน่งของฉัน:
10.
<div id=
"geo_data"
></div>
11.
<script type=
"text/javascript"
>
12.
if
( navigator.geolocation ) {
13.
14.
navigator.geolocation.getCurrentPosition(
function
(location) {
15.
var
location = location.coords;
16.
$(
"#geo_data"
).html(
'lat: '
+location.latitude+
'<br />long: '
+location.longitude+
'<br /> altitude: '
+location.altitude+
'<br /> accuracy: '
+location.accuracy+
'<br /> altitude accuracy: '
+location.altitudeAccuracy+
'<br /> heading: '
+location.heading+
'<br /> speed: '
+location.speed);
17.
},
function
() {
18.
alert(
'มีปัญหาในการตรวจหาตำแหน่ง'
);
19.
});
20.
}
else
{
21.
alert(
'เบราเซอร์นี้ไม่รองรับ geolocation'
);
22.
}
23.
</script>
24.
</body>
25.
</html>