Merge pull request #55 from NightHawk32/gps
Fixes for the marker and center of the map10.3.x-maintenance
commit
fdf84eb984
21
tabs/gps.js
21
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,13 +75,21 @@ TABS.gps.initialize = function (callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var frame = document.getElementById('map');
|
var frame = document.getElementById('map');
|
||||||
if(lat != 0 && lon != 0){
|
if (navigator.onLine) {
|
||||||
frame.contentWindow.postMessage(message, '*');
|
$('#connect').hide();
|
||||||
$('#waiting').hide();
|
|
||||||
$('#loadmap').show();
|
if(lat != 0 && lon != 0){
|
||||||
|
frame.contentWindow.postMessage(message, '*');
|
||||||
|
$('#loadmap').show();
|
||||||
|
$('#waiting').hide();
|
||||||
|
}else{
|
||||||
|
$('#loadmap').hide();
|
||||||
|
$('#waiting').show();
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
$('#connect').show();
|
||||||
|
$('#waiting').hide();
|
||||||
$('#loadmap').hide();
|
$('#loadmap').hide();
|
||||||
$('#waiting').show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,44 +31,46 @@
|
||||||
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');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadMapScript() {
|
function loadMapScript() {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&callback=initialize';
|
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&callback=initialize';
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = loadMapScript;
|
window.onload = loadMapScript;
|
||||||
|
|
||||||
var map;
|
var map;
|
||||||
function initialize() {
|
var marker;
|
||||||
|
|
||||||
var mapOptions = {
|
function initialize() {
|
||||||
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);
|
|
||||||
|
|
||||||
var image = {
|
var mapOptions = {
|
||||||
url: '../images/icons/cf_icon_position.png',
|
zoom: 17,
|
||||||
scaledSize: new google.maps.Size(70, 70)
|
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({
|
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
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// You can use a LatLng literal in place of a google.maps.LatLng object when
|
// 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,
|
// position will be available as a google.maps.LatLng object. In this case,
|
||||||
// we retrieve the marker's position using the
|
// we retrieve the marker's position using the
|
||||||
// google.maps.LatLng.getPosition() method.
|
// google.maps.LatLng.getPosition() method.
|
||||||
var infowindow = new google.maps.InfoWindow({
|
var infowindow = new google.maps.InfoWindow({
|
||||||
content: '<p>Your Location: ' + marker.getPosition() + '</p>'
|
content: '<p>Your Location: ' + marker.getPosition() + '</p>'
|
||||||
});
|
});
|
||||||
|
|
||||||
google.maps.event.addListener(marker, 'click', function() {
|
google.maps.event.addListener(marker, 'click', function() {
|
||||||
infowindow.open(map, marker);
|
infowindow.open(map, 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…
Reference in New Issue