At the moment I’m attending the online course Mobile Web 2: Applications at W3 Tech courses. This post is a summary of the fourth week’s subject JavaScript APIs. (Please note: this is not a thorough objective summary of the course, but just the highlights that I found important for myself to remember.)
Geolocation
A simple example:
if (navigator.geolocation) {
navigator.geolocation.watchPosition(
function (pos) {
$("#lat").text(pos.coords.latitude);
$("#lng").text(pos.coords.longitude);
$("#alt").text(pos.coords.altitude);
$("#hdg").text(pos.coords.heading);
$("#spd").text(pos.coords.speed);
},
function (err) {
$("#status").text("ERROR: " + err.message);
}
)
}