Added comments, shortened bearing code
parent
29bd522915
commit
4c2d18c47c
16
script.js
16
script.js
|
@ -70,7 +70,7 @@ function updateStreetView(loc){
|
||||||
}
|
}
|
||||||
else { //https://stackoverflow.com/a/26609687/3006854
|
else { //https://stackoverflow.com/a/26609687/3006854
|
||||||
brng = Math.atan2( loc.lat-data.location.latLng.lat(), loc.lon-data.location.latLng.lng() );
|
brng = Math.atan2( loc.lat-data.location.latLng.lat(), loc.lon-data.location.latLng.lng() );
|
||||||
brng = 450-(brng*(180/Math.PI)+360)%360;
|
brng = 90-(brng*(180/Math.PI))%360;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set panorama
|
// Set panorama
|
||||||
|
@ -88,7 +88,10 @@ function updateStreetView(loc){
|
||||||
// Check for geolocation
|
// Check for geolocation
|
||||||
if (!navigator.geolocation){
|
if (!navigator.geolocation){
|
||||||
alert("Geolocation not available!");
|
alert("Geolocation not available!");
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// Has geolocation
|
||||||
|
else {
|
||||||
|
|
||||||
// Track geolocation
|
// Track geolocation
|
||||||
navigator.geolocation.watchPosition(
|
navigator.geolocation.watchPosition(
|
||||||
|
@ -108,18 +111,27 @@ if (!navigator.geolocation){
|
||||||
// Got error
|
// Got error
|
||||||
function(err) {
|
function(err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
|
|
||||||
|
// Permission denied
|
||||||
if (err.code==1) {
|
if (err.code==1) {
|
||||||
alert("You can't use this app without granting permission to access your location");
|
alert("You can't use this app without granting permission to access your location");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Location not available
|
||||||
else if (err.code==2) {
|
else if (err.code==2) {
|
||||||
alert("Location data not available.");
|
alert("Location data not available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timeout
|
||||||
else if (err.code==3) {
|
else if (err.code==3) {
|
||||||
alert("Timed out trying to determine location.");
|
alert("Timed out trying to determine location.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other error
|
||||||
else {
|
else {
|
||||||
alert("An unknown error occured while trying to determine location.");
|
alert("An unknown error occured while trying to determine location.");
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|
Loading…
Reference in New Issue