mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 00:05:19 +03:00
Merge pull request #55 from NightHawk32/gps
Fixes for the marker and center of the map
This commit is contained in:
commit
fdf84eb984
2 changed files with 54 additions and 47 deletions
13
tabs/gps.js
13
tabs/gps.js
|
@ -18,7 +18,7 @@ TABS.gps.initialize = function (callback) {
|
||||||
function set_online(){
|
function set_online(){
|
||||||
$('#connect').hide();
|
$('#connect').hide();
|
||||||
$('#waiting').show();
|
$('#waiting').show();
|
||||||
$('#loadmap').show();
|
$('#loadmap').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_offline(){
|
function set_offline(){
|
||||||
|
@ -67,6 +67,7 @@ TABS.gps.initialize = function (callback) {
|
||||||
$('td', row).eq(2).find('progress').val(GPS_DATA.cno[i]);
|
$('td', row).eq(2).find('progress').val(GPS_DATA.cno[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
action: 'center',
|
action: 'center',
|
||||||
lat: lat,
|
lat: lat,
|
||||||
|
@ -74,14 +75,22 @@ TABS.gps.initialize = function (callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var frame = document.getElementById('map');
|
var frame = document.getElementById('map');
|
||||||
|
if (navigator.onLine) {
|
||||||
|
$('#connect').hide();
|
||||||
|
|
||||||
if(lat != 0 && lon != 0){
|
if(lat != 0 && lon != 0){
|
||||||
frame.contentWindow.postMessage(message, '*');
|
frame.contentWindow.postMessage(message, '*');
|
||||||
$('#waiting').hide();
|
|
||||||
$('#loadmap').show();
|
$('#loadmap').show();
|
||||||
|
$('#waiting').hide();
|
||||||
}else{
|
}else{
|
||||||
$('#loadmap').hide();
|
$('#loadmap').hide();
|
||||||
$('#waiting').show();
|
$('#waiting').show();
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$('#connect').show();
|
||||||
|
$('#waiting').hide();
|
||||||
|
$('#loadmap').hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable data pulling
|
// enable data pulling
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
break;
|
break;
|
||||||
case 'center':
|
case 'center':
|
||||||
map.setCenter(new google.maps.LatLng(e.data.lat, e.data.lon));
|
map.setCenter(new google.maps.LatLng(e.data.lat, e.data.lon));
|
||||||
|
marker.setPosition( new google.maps.LatLng( e.data.lat, e.data.lon ) );
|
||||||
|
map.panTo( new google.maps.LatLng( e.data.lat, e.data.lon ) );
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('message error');
|
console.log('message error');
|
||||||
|
@ -44,27 +46,27 @@
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = loadMapScript;
|
window.onload = loadMapScript;
|
||||||
|
|
||||||
var map;
|
var map;
|
||||||
function initialize() {
|
var marker;
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
|
||||||
var mapOptions = {
|
var mapOptions = {
|
||||||
zoom: 17,
|
zoom: 17,
|
||||||
zoomControl: false,
|
zoomControl: false,
|
||||||
streetViewControl: false,
|
streetViewControl: false,
|
||||||
// mapTypeId: google.maps.MapTypeId.SATELLITE,
|
|
||||||
center: {lat: 53.570645, lng: 10.001362}
|
center: {lat: 53.570645, lng: 10.001362}
|
||||||
};
|
};
|
||||||
map = new google.maps.Map(document.getElementById('map-canvas'),
|
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
|
||||||
mapOptions);
|
|
||||||
|
|
||||||
var image = {
|
var image = {
|
||||||
url: '../images/icons/cf_icon_position.png',
|
url: '../images/icons/cf_icon_position.png',
|
||||||
scaledSize: new google.maps.Size(70, 70)
|
scaledSize: new google.maps.Size(70, 70)
|
||||||
};
|
};
|
||||||
|
|
||||||
var marker = new google.maps.Marker({
|
marker = new google.maps.Marker({
|
||||||
icon : image,
|
icon : image,
|
||||||
position: new google.maps.LatLng(53.570645, 10.001362),
|
position: new google.maps.LatLng(53.570645, 10.001362),
|
||||||
map:map
|
map:map
|
||||||
|
@ -85,14 +87,10 @@ var marker = new google.maps.Marker({
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('message', function(e) {
|
window.addEventListener('message', function(e) {
|
||||||
|
|
||||||
var data = e.data;
|
var data = e.data;
|
||||||
var origin = e.origin;
|
var origin = e.origin;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// sandbox docs1: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/sandbox
|
|
||||||
// sandbox docs1: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/sandboxed-content
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue