GPS map checks for online status of the device,

BUGFIX: place marker on GPS position and center map
10.3.x-maintenance
NightHawk32 2015-12-02 15:38:39 -05:00
parent e0baea68b7
commit e6e70c5b5f
2 changed files with 53 additions and 46 deletions

View File

@ -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,13 +75,21 @@ TABS.gps.initialize = function (callback) {
};
var frame = document.getElementById('map');
if(lat != 0 && lon != 0){
frame.contentWindow.postMessage(message, '*');
$('#waiting').hide();
$('#loadmap').show();
if (navigator.onLine) {
$('#connect').hide();
if(lat != 0 && lon != 0){
frame.contentWindow.postMessage(message, '*');
$('#loadmap').show();
$('#waiting').hide();
}else{
$('#loadmap').hide();
$('#waiting').show();
}
}else{
$('#connect').show();
$('#waiting').hide();
$('#loadmap').hide();
$('#waiting').show();
}
}

View File

@ -31,44 +31,46 @@
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');
}
});
function loadMapScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&callback=initialize';
document.head.appendChild(script);
}
function loadMapScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&callback=initialize';
document.head.appendChild(script);
}
window.onload = loadMapScript;
window.onload = loadMapScript;
var map;
function initialize() {
var map;
var marker;
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);
function initialize() {
var image = {
url: '../images/icons/cf_icon_position.png',
scaledSize: new google.maps.Size(70, 70)
};
var mapOptions = {
zoom: 17,
zoomControl: false,
streetViewControl: false,
center: {lat: 53.570645, lng: 10.001362}
};
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({
icon : image,
position: new google.maps.LatLng(53.570645, 10.001362),
map:map
});
marker = new google.maps.Marker({
icon : image,
position: new google.maps.LatLng(53.570645, 10.001362),
map:map
});
// You can use a LatLng literal in place of a google.maps.LatLng object when
@ -76,23 +78,19 @@ var marker = new google.maps.Marker({
// position will be available as a google.maps.LatLng object. In this case,
// we retrieve the marker's position using the
// google.maps.LatLng.getPosition() method.
var infowindow = new google.maps.InfoWindow({
content: '<p>Your Location: ' + marker.getPosition() + '</p>'
});
var infowindow = new google.maps.InfoWindow({
content: '<p>Your Location: ' + marker.getPosition() + '</p>'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
window.addEventListener('message', function(e) {
var data = e.data;
var origin = e.origin;
});
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>