I am using the worldwind nasa earth.
I have created a set of locations (each location has different coordinations) and I need to run a function each time the earth moves from one location to another. The function has to run in the end of each rotation.
The problem is that the time to move between the locations is different (eg from Italy to USA and then to England).
I have unminified the worldwind.js file and tried to run my function inside the t.prototype.goTo function
(t.prototype.goTo = function (t, e) {
if (!t) throw new ArgumentError(d.logMessage(d.LEVEL_SEVERE, "GoToAnimator", "goTo", "missingPosition"));
(this.completionCallback = e),
(this.cancelled = !1),
(this.targetPosition = new f(t.latitude, t.longitude, t.altitude || this.wwd.navigator.range)),
(this.startPosition = new f(this.wwd.navigator.lookAtLocation.latitude, this.wwd.navigator.lookAtLocation.longitude, this.wwd.navigator.range)),
(this.startTime = Date.now());
var i,
r = this.travelTime,
n = c.greatCircleDistance(this.startPosition, this.targetPosition),
o = this.wwd.globe.computePointFromLocation(this.startPosition.latitude, this.startPosition.longitude, new p(0, 0, 0)),
s = this.wwd.globe.computePointFromLocation(this.targetPosition.latitude, this.targetPosition.longitude, new p(0, 0, 0));
this.maxAltitude = o.distanceTo(s);
var a = (this.wwd.navigator.currentState().pixelSizeAtDistance(this.startPosition.altitude) * this.wwd.canvas.clientWidth) / this.wwd.globe.equatorialRadius;
n <= 2 * a && (this.maxAltitude = this.startPosition.altitude),
(this.maxAltitudeReachedTime = this.maxAltitude <= this.wwd.navigator.range ? Date.now() : null),
this.maxAltitude > this.startPosition.altitude
? ((i = Math.max(0, this.maxAltitude - this.startPosition.altitude)), (i += Math.abs(this.targetPosition.altitude - this.maxAltitude)))
: (i = Math.abs(this.targetPosition.altitude - this.startPosition.altitude));
var l = Math.max(n, i / this.wwd.globe.equatorialRadius);
if (0 !== l) {
l < 2 * a && (r = Math.min((l / a) * this.travelTime, this.travelTime)), (r = Math.max(1, r)), (this.panVelocity = n / r), (this.rangeVelocity = i / r);
var h = this,
u = function () {
h.cancelled ? h.completionCallback && h.completionCallback(h) : h.update() ? setTimeout(u, h.animationFrequency) : h.completionCallback && h.completionCallback(h);
};
setTimeout(u, this.animationFrequency);
}
$('#searchButton').css('color', '#000');
})
The custom line I am using for testing is the "$('#searchButton').css('color', '#000');". It works correctly but it runs in the beginning on the earth rotation. I need it to run after the rotation ends.
Any idea how I could make this happen?
Thank you in advance.
The simplest thing is probably to use a timeout:
set the time value to make sure that it always runs after the animation completes.