GPS map checks for online status of the device,

BUGFIX: place marker on GPS position and center map
pull/3/head
NightHawk32 9 years ago
parent e0baea68b7
commit e6e70c5b5f

@ -67,6 +67,7 @@ TABS.gps.initialize = function (callback) {
$('td', row).eq(2).find('progress').val(GPS_DATA.cno[i]);
}
var message = {
action: 'center',
lat: lat,
@ -74,14 +75,22 @@ TABS.gps.initialize = function (callback) {
};
var frame = document.getElementById('map');
if (navigator.onLine) {
$('#connect').hide();
if(lat != 0 && lon != 0){
frame.contentWindow.postMessage(message, '*');
$('#waiting').hide();
$('#loadmap').show();
$('#waiting').hide();
}else{
$('#loadmap').hide();
$('#waiting').show();
}
}else{
$('#connect').show();
$('#waiting').hide();
$('#loadmap').hide();
}
}
// enable data pulling

@ -31,6 +31,8 @@
break;
case 'center':
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) {
console.log('message error');
@ -47,24 +49,24 @@
window.onload = loadMapScript;
var map;
var marker;
function initialize() {
var mapOptions = {
zoom: 17,
zoomControl: false,
streetViewControl: false,
// mapTypeId: google.maps.MapTypeId.SATELLITE,
center: {lat: 53.570645, lng: 10.001362}
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
var image = {
url: '../images/icons/cf_icon_position.png',
scaledSize: new google.maps.Size(70, 70)
};
var marker = new google.maps.Marker({
marker = new google.maps.Marker({
icon : image,
position: new google.maps.LatLng(53.570645, 10.001362),
map:map
@ -85,14 +87,10 @@ var marker = new google.maps.Marker({
});
window.addEventListener('message', function(e) {
var data = e.data;
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>
</head>

Loading…
Cancel
Save