Skip to content

Commit

Permalink
simvar: initialize plane position with browser geolocation data
Browse files Browse the repository at this point in the history
Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
  • Loading branch information
tavip committed May 1, 2021
1 parent cc6a5d7 commit 73804ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/html_ui/WebSim/Simvar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class SimVar {
this.SetSimVarValue("COM STANDBY FREQUENCY:2", null, 122.8);
this.SetSimVarValue("COM ACTIVE FREQUENCY:1", null, 122.8);
this.SetSimVarValue("COM ACTIVE FREQUENCY:2", null, 122.8);
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
this.SetSimVarValue("PLANE LATITUDE", null, position.coords.latitude);
this.SetSimVarValue("PLANE LONGITUDE", null, position.coords.longitude);
});
}
}
/**
* Handle simvar updates for K prefixed variables. These seem to be commands
Expand Down Expand Up @@ -189,6 +195,7 @@ class SimVar {
return val;

//console.log(`unhandled get var ${code} / ${unit}`);

switch (unit) {
case "degrees":
case "degree":
Expand Down

0 comments on commit 73804ec

Please sign in to comment.