谷歌地球问题
我想使用 Google 地球进行演示。我想从旋转地球开始,一段时间后放大到某个位置。旋转的东西可以工作,但不知何故缩放却不起作用。我有以下代码,
var ge;
google.load("earth", "1");
function init() {
google.earth.createInstance('map', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
var oldFlyToSpeed = ge.getOptions().getFlyToSpeed();
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
}
var moveCamera = function(count) {
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
lookAt.setLatitude(lookAt.getLatitude() + .1);
lookAt.setLongitude(lookAt.getLongitude() + 5);
ge.getView().setAbstractView(lookAt);
if (count < 215) {
setTimeout(function() {
moveCamera(count + 1);
}, 150);
} else {
ge.getOptions().setFlyToSpeed(oldFlyToSpeed);
loadRoute();
}
}
var loadRoute = function(){
ge.getOptions().setFlyToSpeed(0.1);
var la = ge.createLookAt('');
la.set(12, -84, 5000, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 750000);
ge.getView().setAbstractView(la);
}
moveCamera(0);
document.getElementById('installed-plugin-version').innerHTML = ge.getPluginVersion();
function failureCB(errorCode){}
我知道 loadRoute();
中的代码可以正常工作,因为我之前测试过。
有人知道这里出了什么问题吗?
I want to use Google Earth for a presentation. I want to start with rotating the globe, and after a while zoom in to a certain location. The rotating stuff works, but somehow the zoom doesn't. I have the following code
var ge;
google.load("earth", "1");
function init() {
google.earth.createInstance('map', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
var oldFlyToSpeed = ge.getOptions().getFlyToSpeed();
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
}
var moveCamera = function(count) {
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
lookAt.setLatitude(lookAt.getLatitude() + .1);
lookAt.setLongitude(lookAt.getLongitude() + 5);
ge.getView().setAbstractView(lookAt);
if (count < 215) {
setTimeout(function() {
moveCamera(count + 1);
}, 150);
} else {
ge.getOptions().setFlyToSpeed(oldFlyToSpeed);
loadRoute();
}
}
var loadRoute = function(){
ge.getOptions().setFlyToSpeed(0.1);
var la = ge.createLookAt('');
la.set(12, -84, 5000, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 750000);
ge.getView().setAbstractView(la);
}
moveCamera(0);
document.getElementById('installed-plugin-version').innerHTML = ge.getPluginVersion();
function failureCB(errorCode){}
I know the peace of code in loadRoute();
works, because i tested that before.
Does anybody know what goes wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码有多个错误,即由于缺少右大括号,loadroute 函数是 moveCamera 函数的一部分。我已经在你的帖子中编辑了它,希望它能起作用。
Your code had multiple errors, namely the loadroute function was part of the moveCamera function due to a missing closing brace. I have edited it in your post so hopefully that should work.