【发布时间】:2021-12-02 16:22:47
【问题描述】:
我正在尝试让 Google 地球回调正常工作,但它们似乎并没有为我触发。我在 Google 地球 API 站点上使用了 View Change Example 作为参考,并且发现它与我的代码之间没有任何区别……但我的代码不起作用!
以下是我的代码的重要部分:
<script type="text/javascript">
var ge;
google.load("earth", "1");
function init() {
document.getElementById('map3d').innerHTML = '';
google.earth.createInstance('map3d', initCallback, failureCallback);
}
function initCallback(pluginInstance) {
ge = pluginInstance;
ge.getWindow().setVisibility(true);
// add a navigation control
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
// Set the FlyTo speed.
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
// add some layers
//ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
//ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
throw (new Error("InitCallback!"));
google.earth.addEventListener(ge.getView(), 'viewchange', function () {
throw (new Error("EVENT!"));
});
}
function failureCallback(errorCode) {
}
</script>
“初始化回调!”错误被正确抛出,但我从未看到“事件!”抛出错误——无论我如何移动地球。
有人看到我做错了吗?非常感谢任何帮助!
【问题讨论】:
标签: javascript dom-events google-earth google-earth-plugin