等待Google Earth完成加载,然后在matlab中执行下一个命令
wait for Google Earth to finish loading before executing next command in matlab
我正在通过COM.将Matlab的模拟数据提供给Google Earth插件
我的问题是,该命令本应在Google Earth完成加载后调用,但在此之前却被调用了。这当然会带来错误。
我可以使用暂停命令来暂停等待谷歌地球加载的代码。但是,这个解决方案并没有那么有效,因为我不知道谷歌地球在不同的机器上加载的速度有多快或有多慢。
我还尝试过使用COM对象的属性。它很近,但没有雪茄。代码看起来像这个
waitfor(h.Document.parentWindow.document,'readyState','complete')
或者这个:
while strcmp(h.Document.parentWindow.document.readyState,'complete')== 0
pause(1);
end
是否有可以使用的对象属性?谢谢
找到了解决方案!
GoogleEarth插件在加载完成后将调用"initCallback"方法。
通过在"initCallback"方法上添加一行,我将html文档的标题更改为其他名称,这表明插件已加载。
function initCallback(pluginInstance) {
ge = pluginInstance;
ge.getWindow().setVisibility(true);
// tell the application the plugin is ready
//(window.external.JSInitSuccessCallback_(pluginInstance);
document.title = "Google Earth Plugin - Ready";
// prevent mouse navigation in the plugin
ge.getOptions().setMouseNavigationEnabled(false);
}
在MATLAB的最后,我只是添加了一个while循环,比较html文档标题,暂停执行,直到插件加载完成。
while strcmp(h.Document.title,'Google Earth Plugin - Ready')~=1
pause(0.01)
end
也许还有其他更优雅的解决方案,喜欢听你的反馈
相关文章:
- 无法在通过jQuery的ajax加载的页面中执行javascript
- JavaScript执行暂时挂起页面
- 如何在ReactJS JSX中执行嵌套的if-else语句
- 当js函数's已执行
- 哪个先执行
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- HTML表单提交时未执行外部函数
- 在Safari执行javascript之前对其进行修改
- Amd,希望确保某个东西总是最后执行
- 在Windows 10中自动执行例行程序(主要与浏览器交互)
- 递归使用 eval() 是检查程序执行的好方法吗?
- 如何做到这一点,使代码在不传递条件后执行函数
- 如何在执行此特定onclick事件时执行JavaScript函数
- 如何在从浏览缓存加载页面时执行javascript
- Jquery表单验证插件-如果选中复选框,如何在提交时执行某些操作
- Jquery:代码在rails中的页面加载时未执行
- 如何防止jQueryonclick事件中的Ruby方法在页面刷新时执行
- JavaScript动画从不执行
- 为什么onsubmit函数似乎没有执行
- 等待Google Earth完成加载,然后在matlab中执行下一个命令