Hi Razz,
I've got start and stop buttons implemented on a test platform, at
http://gaialab.asu.edu/Test. cjorba is correct, you have to trigger
the rotation when you add the frameend listener. IO did it with the
following code and HTML:
<script>
google.load("earth", "1");
var ge = null;
var speed = 15; // degrees per second
var lastMillis = (new Date()).getTime();
function init() {
google.earth.createInstance("map3d", initCallback,
failureCallback);
toggleButtons("start");
}
function failureCallback(object) {
}
function initCallback(object) {
ge = object;
ge.getWindow().setVisibility(true);
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
google.earth.addEventListener(ge, "frameend", rotateEarth);
}
function rotateEarth(){
var now = (new Date()).getTime();
// dt is the delta-time since last tick, in seconds
var dt = (now - lastMillis) / 1000.0;
lastMillis = now;
var lookAt = ge.getView().copyAsLookAt
(ge.ALTITUDE_RELATIVE_TO_GROUND);
lookAt.setLongitude(lookAt.getLongitude() + speed*dt);
lookAt.setHeading(0); // Workaround for heading bug, issue
#148
ge.getView().setAbstractView(lookAt);
}
function startRotation() {
google.earth.addEventListener(ge, "frameend", rotateEarth);
rotateEarth();
}
function stopRotation() {
google.earth.removeEventListener(ge, "frameend",
rotateEarth);
}
function toggleButtons(val) {
frm=document.forms[0]
if(val=="start")
{frm.start.disabled=true;frm.stop.disabled=false;}
if(val=="stop")
{frm.start.disabled=false;frm.stop.disabled=true;}
}
</script>
</head>
<body onload='init()' id='body'>
<center>
<div id='map3d_container' style='border: thin solid blue;
height: 600px; width: 800px;'>
<div id='map3d' style='height: 100%;'></div>
</div>
<form>
<button id="start" onclick="startRotation(); toggleButtons
('start')">Start Rotation</button>
<button id="stop" onclick="stopRotation(); toggleButtons
('stop')">Stop Rotation</button>
</form>
</center>
</body>
</html>
-Steve