mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-11-28 23:38:13 +00:00
fix(app): live GPS marker/follow updates continuously, not only on RX
The map's position marker only moved when a packet arrived, so it appeared to hang and jump. GPS fixes (watchPosition) now feed the map directly via setPosition; hexes are still added only on a real RX.
This commit is contained in:
1 parent
baeed272fc
commit
91bbe1a67f
4 files changed
+22
-9
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "corescope-rx",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Mobile RX coverage capture for CoreScope: BLE companion → MQTT (GPS + SNR/RSSI + multibyte)",
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ async function connectAll() {
|
||||
els('companionInfo').textContent = state.companionPubkey.slice(0, 20) + '…';
|
||||
dbg('SELF_INFO → ' + (info.name || '(unnamed)') + ' ' + state.companionPubkey);
|
||||
|
||||
state.gps.start();
|
||||
state.gps.start((fix) => { if (state.localMap) state.localMap.setPosition(fix.lat, fix.lon); });
|
||||
|
||||
const s3 = step('③ Connecting to ON8AR CoreScope…', 'pending');
|
||||
if (MQTT_CFG.url) {
|
||||
|
||||
+7
-2
@@ -3,10 +3,15 @@
|
||||
export class Gps {
|
||||
constructor() { this._last = null; this._watchId = null; }
|
||||
|
||||
start() {
|
||||
// start(onFix): begins watching; onFix (optional) fires on every position
|
||||
// update so the UI can track GPS continuously, independent of RX packets.
|
||||
start(onFix) {
|
||||
if (!navigator.geolocation) throw new Error('geolocation unavailable');
|
||||
this._watchId = navigator.geolocation.watchPosition(
|
||||
(p) => { this._last = { lat: p.coords.latitude, lon: p.coords.longitude, acc_m: p.coords.accuracy }; },
|
||||
(p) => {
|
||||
this._last = { lat: p.coords.latitude, lon: p.coords.longitude, acc_m: p.coords.accuracy };
|
||||
if (onFix) onFix(this._last);
|
||||
},
|
||||
() => {},
|
||||
{ enableHighAccuracy: true, maximumAge: 5000, timeout: 15000 }
|
||||
);
|
||||
|
||||
+13
-5
@@ -71,15 +71,23 @@ export function createLocalMap(containerId) {
|
||||
if (nr !== res) { res = nr; rebuild(); }
|
||||
});
|
||||
|
||||
// setPos moves the "you are here" marker and (when following) keeps it centred.
|
||||
// Called continuously from GPS — independent of RX — so the position is live.
|
||||
function setPos(lat, lon) {
|
||||
if (lat == null || lon == null) return;
|
||||
if (!me) me = L.circleMarker([lat, lon], { radius: 5, color: '#fff', weight: 2, fillColor: '#3b82f6', fillOpacity: 1 }).addTo(map);
|
||||
else me.setLatLng([lat, lon]);
|
||||
if (!centered) { centered = true; map.setView([lat, lon], 15); } // initial zoom
|
||||
else if (follow) map.panTo([lat, lon]); // follow GPS, keep current zoom
|
||||
}
|
||||
|
||||
return {
|
||||
addPoint(lat, lon, snr) {
|
||||
setPosition(lat, lon) { setPos(lat, lon); }, // live GPS, no hex
|
||||
addPoint(lat, lon, snr) { // an RX: add a hex + sync position
|
||||
points.push({ lat, lon, snr });
|
||||
if (points.length > POINT_CAP) points.shift();
|
||||
upsert(lat, lon, snr);
|
||||
if (!me) me = L.circleMarker([lat, lon], { radius: 5, color: '#fff', weight: 2, fillColor: '#3b82f6', fillOpacity: 1 }).addTo(map);
|
||||
else me.setLatLng([lat, lon]);
|
||||
if (!centered) { centered = true; map.setView([lat, lon], 15); } // initial zoom
|
||||
else if (follow) map.panTo([lat, lon]); // follow GPS, keep current zoom
|
||||
setPos(lat, lon);
|
||||
},
|
||||
invalidate() { setTimeout(() => { try { map.invalidateSize(); } catch (e) {} }, 150); },
|
||||
destroy() { try { map.remove(); } catch (e) {} },
|
||||
|
||||
Reference in new issue
Block a user