等待 Google Earth 完成加载,然后再在 matlab 中执行下一个命令
我正在致力于通过 COM 将 Matlab 的模拟数据提供给 Google Earth 插件。
我的问题是,该命令应该在 Google 地球完成加载后调用,但在此之前调用。这当然会带来错误。
我可以使用暂停命令来暂停等待 Google 地球加载的代码。但是,这个解决方案并不是那么有效,因为我不知道 Google 地球在不同机器上的加载速度到底有多快或多慢。
我还尝试过使用 COM 对象的属性。很接近,但没有雪茄。代码看起来像这样
waitfor(h.Document.parentWindow.document,'readyState','complete')
或也这样:
while strcmp(h.Document.parentWindow.document.readyState,'complete')== 0
pause(1);
end
是否有任何可以使用的对象属性?谢谢!
I am working on feeding Matlab's simulation data to Google Earth Plug-in via COM.
My problem is that the command,which should be invoked after Google Earth finished loading, is invoked before that. That brings of course error.
I could use the pause command to pause the code waiting the Google Earth to load. But, this solution is not that efficient, as I don't know exactly how fast or how slow Google Earth will load on different machines.
I've also tried using the properties of the COM object. It was close, but no cigar. The code looks like this
waitfor(h.Document.parentWindow.document,'readyState','complete')
or also this one:
while strcmp(h.Document.parentWindow.document.readyState,'complete')== 0
pause(1);
end
Is there any object properties that could be used? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到解决方案了!
Google 地球插件在完成加载后将调用“initCallback”方法。
通过在“initCallback”方法上添加一行,我将 html 文档的标题更改为其他名称,这表明插件已加载。
在 MATLAB 的最后,我只是添加了一个 while 循环,比较 html 文档标题,暂停执行,直到插件加载完成。
也许还有其他更优雅的解决方案,很高兴听到您的反馈
Found the solution!
Google Earth Plug-in will call the "initCallback" method when it finished loading.
By adding a line on "initCallback" method, I change the title of my html document to other name, which indicates that the plugin is loaded.
At MATLAB's end, I just added the a while loop, comparing the html document title, pausing the executing until the plugin is finished loading.
Maybe there is other more elegant solution, love to hear your feedbacks