mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 08:15:19 +03:00
Map now shows up on satfix and updates the position of the marker
This commit is contained in:
parent
938d8b522c
commit
f596abee0f
2 changed files with 42 additions and 23 deletions
63
tabs/gps.js
63
tabs/gps.js
|
@ -15,6 +15,18 @@ TABS.gps.initialize = function (callback) {
|
|||
|
||||
MSP.send_message(MSP_codes.MSP_STATUS, false, false, load_html);
|
||||
|
||||
function set_online(){
|
||||
$('#connect').hide();
|
||||
$('#waiting').show();
|
||||
$('#loadmap').show();
|
||||
}
|
||||
|
||||
function set_offline(){
|
||||
$('#connect').show();
|
||||
$('#waiting').hide();
|
||||
$('#loadmap').hide();
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
// translate to user-selected languageconsole.log('Online');
|
||||
localize();
|
||||
|
@ -54,13 +66,29 @@ TABS.gps.initialize = function (callback) {
|
|||
$('td', row).eq(1).text(GPS_DATA.quality[i]);
|
||||
$('td', row).eq(2).find('progress').val(GPS_DATA.cno[i]);
|
||||
}
|
||||
|
||||
var message = {
|
||||
action: 'center',
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
};
|
||||
|
||||
var frame = document.getElementById('map');
|
||||
if(lat != 0 && lon != 0){
|
||||
frame.contentWindow.postMessage(message, '*');
|
||||
$('#waiting').hide();
|
||||
$('#loadmap').show();
|
||||
}else{
|
||||
$('#loadmap').hide();
|
||||
$('#waiting').show();
|
||||
}
|
||||
}
|
||||
|
||||
// enable data pulling
|
||||
GUI.interval_add('gps_pull', function gps_update() {
|
||||
// avoid usage of the GPS commands until a GPS sensor is detected for targets that are compiled without GPS support.
|
||||
if (!have_sensor(CONFIG.activeSensors, 'gps')) {
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
|
||||
get_raw_gps_data();
|
||||
|
@ -75,30 +103,19 @@ TABS.gps.initialize = function (callback) {
|
|||
//check for internet connection on load
|
||||
if (navigator.onLine) {
|
||||
console.log('Online');
|
||||
$('#connect').hide();
|
||||
$('#waiting').show();
|
||||
$('#loadmap').show();
|
||||
|
||||
set_online();
|
||||
} else {
|
||||
console.log('Offline');
|
||||
$('#connect').show();
|
||||
$('#waiting').hide();
|
||||
$('#loadmap').hide();
|
||||
|
||||
set_offline();
|
||||
}
|
||||
|
||||
$("#check").on('click',function(){
|
||||
if (navigator.onLine) {
|
||||
console.log('Online');
|
||||
$('#connect').hide();
|
||||
$('#waiting').show();
|
||||
$('#loadmap').show();
|
||||
|
||||
set_online();
|
||||
} else {
|
||||
console.log('Offline');
|
||||
$('#connect').show();
|
||||
$('#waiting').hide();
|
||||
$('#loadmap').hide();
|
||||
set_offline();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -107,17 +124,17 @@ TABS.gps.initialize = function (callback) {
|
|||
$('#zoom_in').click(function() {
|
||||
console.log('zoom in');
|
||||
var message = {
|
||||
action: 'zoom_in',
|
||||
};
|
||||
frame.contentWindow.postMessage(message, '*');
|
||||
action: 'zoom_in',
|
||||
};
|
||||
frame.contentWindow.postMessage(message, '*');
|
||||
});
|
||||
|
||||
$('#zoom_out').click(function() {
|
||||
console.log('zoom out');
|
||||
var message = {
|
||||
action: 'zoom_out'
|
||||
};
|
||||
frame.contentWindow.postMessage(message, '*');
|
||||
var message = {
|
||||
action: 'zoom_out'
|
||||
};
|
||||
frame.contentWindow.postMessage(message, '*');
|
||||
});
|
||||
|
||||
GUI.content_ready(callback);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
zoom--;
|
||||
map.setZoom(zoom);
|
||||
break;
|
||||
case 'center':
|
||||
map.setCenter(new google.maps.LatLng(e.data.lat, e.data.lon));
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('message error');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue