diff --git a/html/planeObject.js b/html/planeObject.js
index 8cca13b..34daac3 100644
--- a/html/planeObject.js
+++ b/html/planeObject.js
@@ -3006,7 +3006,17 @@ function routeDoLookup() {
g.route_check_checking = null;
return;
}
+ if (g.route_check_checking.length < 10 && currentTime - g.route_last_lookup < 3.5) {
+ // only do lookups every 3 seconds if we don't have many routes to check
+ if (debugRoute) {
+ console.log('delaying route check, trying to bundle request for 3 seconds');
+ }
+ return;
+ }
+
g.route_check_in_flight = true;
+ g.route_last_lookup = currentTime;
+
if (debugRoute) {
console.log(`${currentTime}: g.route_check_checking:`, g.route_check_checking);
}
diff --git a/html/script.js b/html/script.js
index 4f38af3..8346d65 100644
--- a/html/script.js
+++ b/html/script.js
@@ -11,6 +11,7 @@ g.route_cache = [];
g.route_check_todo = {};
g.route_check_in_flight = false;
g.route_next_lookup = 0;
+g.route_last_lookup = 0;
g.mapOrientation = mapOrientation;
@@ -5739,7 +5740,7 @@ function checkMovement() {
return;
}
- let currentTime = new Date().getTime()/1000;
+ let currentTime = Date.now()/1000;
if (currentTime > g.route_next_lookup && !g.route_check_in_flight) {
// check if it's time to send a batch of request to the API server
g.route_next_lookup = currentTime + 1;