Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"js/tabs/map.js",
"/js/libraries/openlayers/ol.css",
"/js/libraries/openlayers/ol.js",
"/images/icons/cf_icon_position.png"]
"/images/icons/cf_icon_position.png",
"/images/icons/cf_icon_position_nofix.png"]
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"js/tabs/map.js",
"/js/libraries/openlayers/ol.css",
"/js/libraries/openlayers/ol.js",
"/images/icons/cf_icon_position.png"
"/images/icons/cf_icon_position.png",
"/images/icons/cf_icon_position_nofix.png"
]
}
]
Expand Down
Binary file added src/images/icons/cf_icon_position_nofix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ TABS.gps.initialize = function (callback) {
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() {
var lat = GPS_DATA.lat / 10000000;
var lon = GPS_DATA.lon / 10000000;
Expand Down Expand Up @@ -81,16 +84,20 @@ TABS.gps.initialize = function (callback) {
if (navigator.onLine) {
$('#connect').hide();

//if(lat != 0 && lon != 0){
if(GPS_DATA.fix){
if (GPS_DATA.fix) {
gpsWasFixed = true;
frame.contentWindow.postMessage(message, '*');
$('#loadmap').show();
$('#waiting').hide();
}else{
} else if (!gpsWasFixed) {
$('#loadmap').hide();
$('#waiting').show();
} else {
message.action = 'nofix';
frame.contentWindow.postMessage(message, '*');
}
}else{
gpsWasFixed = false;
$('#connect').show();
$('#waiting').hide();
$('#loadmap').hide();
Expand Down
40 changes: 30 additions & 10 deletions src/js/tabs/map.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const DEFAULT_ZOOM = 16,
DEFAULT_LON = 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,
map,
mapView,
marker;
iconStyle,
iconStyleNoFix,
iconFeature;

window.onload = initializeMap;

Expand All @@ -30,17 +33,30 @@ function initializeMap() {
controls: []
});

var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 1],
opacity: 1,
scale: 0.5,
src: ICON_IMAGE
}))
var icon = new ol.style.Icon(({
anchor: [0.5, 1],
opacity: 1,
scale: 0.5,
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);
var iconFeature = new ol.Feature({
iconFeature = new ol.Feature({
geometry: iconGeometry
});

Expand Down Expand Up @@ -73,11 +89,15 @@ function processMapEvents(e) {
break;

case 'center':
iconFeature.setStyle(iconStyle);
var center = ol.proj.fromLonLat([e.data.lon, e.data.lat]);
mapView.setCenter(center);
iconGeometry.setCoordinates(center);
break;

case 'nofix':
iconFeature.setStyle(iconStyleNoFix);
break;
}

} catch (e) {
Expand Down