diff --git a/images/earth.html b/images/earth.html
index 02827db1b9b36281b6824f57f24008a4e0cdac02..afa5fce015167f56d4eabacff0100cd7f5c9807c 100644
--- a/images/earth.html
+++ b/images/earth.html
@@ -23,12 +23,17 @@ var lastAlt = 0;
var currLat = 47.3769;
var currLon = 8.549444;
var currAlt = 470;
+
+var currentCameraLatitude = 0;
+var currentCameraLongitude = 0;
+var currentCameraAltitude = 0;
+
var currFollowHeading = 0.0;
var homeLat = 0;
var homeLon = 0;
var homeAlt = 0;
-var homeViewRange = 500;
+var homeViewRange = 800;
var homeLocation = null;
var homeGroundLevel = 0;
@@ -85,6 +90,8 @@ var newWaypointLongitude = 0;
var newWaypointAltitude = 0;
var newWaypointPending = false;
+var clickMode = 0;
+
var homePlacemark = null;
function getGlobal(variable)
@@ -107,6 +114,28 @@ function setDraggingAllowed(allowed)
draggingAllowed = allowed;
}
+function sampleCurrentPosition()
+{
+ var thisView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
+ currentCameraLatitude = thisView.getLatitude();
+ currentCameraLongitude = thisView.getLongitude();
+ currentCameraGroundAltitude = ge.getGlobe().getGroundAltitude(currentCameraLatitude, currentCameraLongitude);
+}
+
+function enableSetHomeMode()
+{
+ clickMode = 1;
+}
+
+function setLookAtLatLon(lat, lon)
+{
+ // Keep the current altitude above ground, just move the position
+ currView = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
+ currView.setLatitude(lat);
+ currView.setLongitude(lon);
+ ge.getView().setAbstractView(currView);
+}
+
function setNewWaypointPending(pending)
{
newWaypointPending = pending;
@@ -140,16 +169,35 @@ function enableEventListener()
// listen for mousedown on the window (look specifically for point placemarks)
google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event)
{
+if (clickMode == 1)
+ {
+ // Set home mode
+ dragWaypointIndex = 'HOME';
+ document.getElementById('JScript_dragWaypointIndex').setAttribute('value',dragWaypointIndex);
+ dragWaypointLatitude = event.getLatitude();
+ dragWaypointLongitude = event.getLongitude();
+ dragWaypointAltitude = ge.getGlobe().getGroundAltitude(dragWaypointLatitude, dragWaypointLongitude);
+ dragWaypointPending = true;
+ document.getElementById('JScript_dragWaypointLatitude').setAttribute('value',dragWaypointLatitude);
+ document.getElementById('JScript_dragWaypointLongitude').setAttribute('value',dragWaypointLongitude);
+ document.getElementById('JScript_dragWaypointAltitude').setAttribute('value',dragWaypointAltitude);
+ document.getElementById('JScript_dragWaypointPending').setAttribute('value',true);
+ setGCSHome(dragWaypointLatitude, dragWaypointLongitude, dragWaypointAltitude);
+}
+
if (event.getTarget().getType() == 'KmlPlacemark' &&
event.getTarget().getGeometry().getType() == 'KmlPoint') {
var placemark = event.getTarget();
event.preventDefault();
if (draggingAllowed)
{
+ if (clickMode == 0)
+ {
dragInfo = {
placemark: event.getTarget(),
dragged: false
};
+ }
}
}
});
@@ -157,7 +205,7 @@ google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event)
// listen for mousemove on the globe
google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
{
- if (draggingAllowed)
+ if (draggingAllowed && (clickMode == 0))
{
if (dragInfo) {
event.preventDefault();
@@ -182,7 +230,7 @@ google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
// listen for mouseup on the window
google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event)
{
- if (draggingAllowed)
+ if (draggingAllowed && (clickMode == 0))
{
if (dragInfo) {
if (dragInfo.dragged)
@@ -206,6 +254,7 @@ google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event)
dragInfo = null;
}
}
+ clickMode = 0;
});
// Listen for wp creation request on the globe
@@ -235,6 +284,9 @@ function setCurrAircraft(id)
function setGCSHome(lat, lon, alt)
{
+ // Only update if position actually changed
+ if (lat != homeLat || lon != homeLon || alt != homeAlt)
+ {
homeLat = lat;
homeLon = lon;
homeAlt = alt;
@@ -265,12 +317,15 @@ function setGCSHome(lat, lon, alt)
}
else
{
- var location = ge.createPoint('');
- location.setLatitude(lat);
- location.setLongitude(lon);
- location.setAltitude(alt);
- homePlacemark.setGeometry(location);
- homePlacemark.setDescription('HOME');
+ var location = ge.createPoint('');
+ if (location.getLatitude() != lat || location.getLongitude() != lon || location.getAltitude() != alt)
+ {
+ location.setLatitude(lat);
+ location.setLongitude(lon);
+ location.setAltitude(alt);
+ homePlacemark.setGeometry(location);
+ homePlacemark.setDescription('HOME');
+ }
}
homeGroundLevel = ge.getGlobe().getGroundAltitude(lat,lon);
@@ -278,6 +333,7 @@ function setGCSHome(lat, lon, alt)
{
homeGroundLevel = alt;
}
+ }
}
function updateWaypointListLength(id, len)
@@ -560,14 +616,8 @@ function setViewMode(mode)
{
lastTilt = currView.getTilt();
lastHeading = currView.getHeading();
- //var lastLat2 = currView.getLatitude();
- //var lastLon2 = currView.getLongitude();
- //var lastAlt2 = currView.getAltitude();
currView.setTilt(0);
currView.setHeading(0);
- //currView.setLatitude(lastLat2);
- //currView.setLongitude(lastLon2);
- //currView.setAltitude(lastAlt2);
}
viewMode = mode;
@@ -628,5 +678,8 @@ function failureCallback(object)
+
+
+