mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 17:55:24 +03:00
Merge pull request #1341 from McGiverGim/fix_flickering_gps
Remove flickering when fix is unstable
This commit is contained in:
commit
daac0a6c58
5 changed files with 44 additions and 15 deletions
|
@ -53,7 +53,8 @@
|
||||||
"js/tabs/map.js",
|
"js/tabs/map.js",
|
||||||
"/js/libraries/openlayers/ol.css",
|
"/js/libraries/openlayers/ol.css",
|
||||||
"/js/libraries/openlayers/ol.js",
|
"/js/libraries/openlayers/ol.js",
|
||||||
"/images/icons/cf_icon_position.png"]
|
"/images/icons/cf_icon_position.png",
|
||||||
|
"/images/icons/cf_icon_position_nofix.png"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
"js/tabs/map.js",
|
"js/tabs/map.js",
|
||||||
"/js/libraries/openlayers/ol.css",
|
"/js/libraries/openlayers/ol.css",
|
||||||
"/js/libraries/openlayers/ol.js",
|
"/js/libraries/openlayers/ol.js",
|
||||||
"/images/icons/cf_icon_position.png"
|
"/images/icons/cf_icon_position.png",
|
||||||
|
"/images/icons/cf_icon_position_nofix.png"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
BIN
src/images/icons/cf_icon_position_nofix.png
Normal file
BIN
src/images/icons/cf_icon_position_nofix.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
|
@ -42,6 +42,9 @@ TABS.gps.initialize = function (callback) {
|
||||||
MSP.send_message(MSPCodes.MSP_GPS_SV_INFO, false, false, update_ui);
|
MSP.send_message(MSPCodes.MSP_GPS_SV_INFO, false, false, update_ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To not flicker the divs while the fix is unstable
|
||||||
|
var gpsWasFixed = false;
|
||||||
|
|
||||||
function update_ui() {
|
function update_ui() {
|
||||||
var lat = GPS_DATA.lat / 10000000;
|
var lat = GPS_DATA.lat / 10000000;
|
||||||
var lon = GPS_DATA.lon / 10000000;
|
var lon = GPS_DATA.lon / 10000000;
|
||||||
|
@ -81,16 +84,20 @@ TABS.gps.initialize = function (callback) {
|
||||||
if (navigator.onLine) {
|
if (navigator.onLine) {
|
||||||
$('#connect').hide();
|
$('#connect').hide();
|
||||||
|
|
||||||
//if(lat != 0 && lon != 0){
|
if (GPS_DATA.fix) {
|
||||||
if(GPS_DATA.fix){
|
gpsWasFixed = true;
|
||||||
frame.contentWindow.postMessage(message, '*');
|
frame.contentWindow.postMessage(message, '*');
|
||||||
$('#loadmap').show();
|
$('#loadmap').show();
|
||||||
$('#waiting').hide();
|
$('#waiting').hide();
|
||||||
}else{
|
} else if (!gpsWasFixed) {
|
||||||
$('#loadmap').hide();
|
$('#loadmap').hide();
|
||||||
$('#waiting').show();
|
$('#waiting').show();
|
||||||
|
} else {
|
||||||
|
message.action = 'nofix';
|
||||||
|
frame.contentWindow.postMessage(message, '*');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
gpsWasFixed = false;
|
||||||
$('#connect').show();
|
$('#connect').show();
|
||||||
$('#waiting').hide();
|
$('#waiting').hide();
|
||||||
$('#loadmap').hide();
|
$('#loadmap').hide();
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
const DEFAULT_ZOOM = 16,
|
const DEFAULT_ZOOM = 16,
|
||||||
DEFAULT_LON = 0,
|
DEFAULT_LON = 0,
|
||||||
DEFAULT_LAT = 0,
|
DEFAULT_LAT = 0,
|
||||||
ICON_IMAGE = '/images/icons/cf_icon_position.png';
|
ICON_IMAGE = '/images/icons/cf_icon_position.png',
|
||||||
|
ICON_IMAGE_NOFIX = '/images/icons/cf_icon_position_nofix.png';
|
||||||
|
|
||||||
var iconGeometry,
|
var iconGeometry,
|
||||||
map,
|
map,
|
||||||
mapView,
|
mapView,
|
||||||
marker;
|
iconStyle,
|
||||||
|
iconStyleNoFix,
|
||||||
|
iconFeature;
|
||||||
|
|
||||||
window.onload = initializeMap;
|
window.onload = initializeMap;
|
||||||
|
|
||||||
|
@ -30,17 +33,30 @@ function initializeMap() {
|
||||||
controls: []
|
controls: []
|
||||||
});
|
});
|
||||||
|
|
||||||
var iconStyle = new ol.style.Style({
|
var icon = new ol.style.Icon(({
|
||||||
image: new ol.style.Icon(({
|
anchor: [0.5, 1],
|
||||||
anchor: [0.5, 1],
|
opacity: 1,
|
||||||
opacity: 1,
|
scale: 0.5,
|
||||||
scale: 0.5,
|
src: ICON_IMAGE
|
||||||
src: ICON_IMAGE
|
}));
|
||||||
}))
|
|
||||||
|
var iconNoFix = new ol.style.Icon(({
|
||||||
|
anchor: [0.5, 1],
|
||||||
|
opacity: 1,
|
||||||
|
scale: 0.5,
|
||||||
|
src: ICON_IMAGE_NOFIX
|
||||||
|
}));
|
||||||
|
|
||||||
|
iconStyle = new ol.style.Style({
|
||||||
|
image: icon
|
||||||
|
});
|
||||||
|
|
||||||
|
iconStyleNoFix = new ol.style.Style({
|
||||||
|
image: iconNoFix
|
||||||
});
|
});
|
||||||
|
|
||||||
iconGeometry = new ol.geom.Point(lonLat);
|
iconGeometry = new ol.geom.Point(lonLat);
|
||||||
var iconFeature = new ol.Feature({
|
iconFeature = new ol.Feature({
|
||||||
geometry: iconGeometry
|
geometry: iconGeometry
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,11 +89,15 @@ function processMapEvents(e) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'center':
|
case 'center':
|
||||||
|
iconFeature.setStyle(iconStyle);
|
||||||
var center = ol.proj.fromLonLat([e.data.lon, e.data.lat]);
|
var center = ol.proj.fromLonLat([e.data.lon, e.data.lat]);
|
||||||
mapView.setCenter(center);
|
mapView.setCenter(center);
|
||||||
iconGeometry.setCoordinates(center);
|
iconGeometry.setCoordinates(center);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'nofix':
|
||||||
|
iconFeature.setStyle(iconStyleNoFix);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue