Skip to content

Commit

Permalink
Merge pull request #217 from stadiamaps/browser-geolocaton-speed-fix
Browse files Browse the repository at this point in the history
Browser geolocaton speed fix
  • Loading branch information
ianthetechie authored Sep 2, 2024
2 parents 5324e58 + 25d0a6d commit 3dd8b15
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
12 changes: 11 additions & 1 deletion update-release-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ set -e
set -u

version=$1

# Swift
sed -i "" -E "s/(let releaseTag = \")[^\"]+(\")/\1$version\2/g" Package.swift

# Android
sed -i "" -E "s/(version = \")[^\"]+(\")/\1$version\2/g" android/build.gradle

# Rust
awk '{ if (!done && /version = \"/) { sub(/(version = \")[^\"]+(\")/, "version = \"" newVersion "\""); done=1 } print }' newVersion="$version" common/ferrostar/Cargo.toml > tmpfile && mv tmpfile common/ferrostar/Cargo.toml
cd common && cargo check && cd ..

git add Package.swift android/build.gradle common/Cargo.lock common/ferrostar/Cargo.toml
# Web components
sed -i "" -E "s/(\"version\": \")[^\"]+(\")/\1$version\2/g" web/package.json
cd web && npm install && cd ..

git add Package.swift android/build.gradle common/Cargo.lock common/ferrostar/Cargo.toml web/package.json web/package-lock.json
6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
}

// Initialize Ferrostar and the control buttons
if ( document.readyState === "complete" ) {
onload();
} else {
if ( document.readyState === "loading" ) {
document.addEventListener("DOMContentLoaded", onload);
} else {
onload();
}
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Jacob Fielding <[email protected]>",
"Luke Seelenbinder <[email protected]>"
],
"version": "0.1.4",
"version": "0.9.2",
"license": "BSD-3-Clause",
"type": "module",
"main": "./dist/ferrostar-webcomponents.js",
Expand Down
12 changes: 9 additions & 3 deletions web/src/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,21 @@ export class BrowserLocationProvider {
enableHighAccuracy: true,
};

this.geolocationWatchId = navigator.geolocation.watchPosition((position) => {
this.lastLocation = {
this.geolocationWatchId = navigator.geolocation.watchPosition((position: GeolocationPosition) => {
let speed = null;
if (position.coords.speed) {
speed = {
value: position.coords.speed
}
}
this.lastLocation = {
coordinates: { lat: position.coords.latitude, lng: position.coords.longitude },
horizontalAccuracy: position.coords.accuracy,
courseOverGround: {
degrees: Math.floor(position.coords.heading || 0),
},
timestamp: position.timestamp,
speed: position.coords.speed,
speed: speed,
};

if (this.updateCallback) {
Expand Down

0 comments on commit 3dd8b15

Please sign in to comment.