使用 Google 地球插件管理气球的最明智方法是什么?
我的公司开发了一个 Web 应用程序(使用 GWT 在 Java 中),该应用程序使用 Google Earth 插件来显示地球上的特定站点和其他数据。我们目前正在按使用情况管理气球,这意味着需要显示气球的每个功能都在管理气球本身的销毁(如果需要)和创建。这会导致以下问题:如果我们尝试打开一个气球而另一个气球仍然打开,GE 插件有时会崩溃。尽管我们几乎在所有情况下都解决了这个问题,但我认为集中管理气球而不是在每个使用气球的地方管理是明智的。
障碍:
要显示的站点很多,其位置必须非常精确;
多个图层正在使用,每个图层都可能显示气球;
有没有人创建了一个“BalloonManager”类型的东西来处理这类事情?你会怎么做?
My company develops a web application (in Java using GWT) that employs the Google Earth plugin to display specific sites and other data on the globe. We're currently managing balloons on a per-use basis, meaning each function that needs to display a balloon is managing the destruction(if needed) and creation of the balloon itself. This leads to issues where the GE plugin will sometimes crash if we try to open a balloon while another is still open. Though we've worked this out in almost every case, I'm thinking it would be smart(er) to manage the balloons centrally, instead of in each place that uses them.
Hurdles:
many sites to show, the locations of which must be very precise;
multiple layers are in use, each of which may show balloons;
Has anyone created a "BalloonManager"-type thing that handles this sort of thing? How might you do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您应该使用封装,看看将气球创建移动到一个单独的方法中。
另外,关于“如果我们尝试在另一个气球仍打开时打开一个气球,GE 插件有时会崩溃的问题”,请确保在打开任何气球之前简单地调用
ge.setBalloon(null)
,或者更好的是,只需重复使用任何当前的气球,而不是创建一个新的气球(如果有)。下面的代码应该有助于解释 - 它使用了您需要的 api 方法,所以它应该有一些用处。
如果您不想将某个功能传递给该方法,那么将该方法设置为接受诸如纬度和经度之类的东西作为双精度值将是相当简单的。
It sounds like you should be using encapsulation, look at moving the balloon creation into a single separate method.
Also, with regard to "issues where the GE plugin will sometimes crash if we try to open a balloon while another is still open" - make sure you simply call
ge.setBalloon(null)
before opening any balloons, or better still, simply reuse any current balloon rather than creating a new one if it is available.The following code should help to explain - it is using the api methods you would need so it should be of some use.
If you did not want to pass a feature to the method, it would be fairly trivial to ammed the method to accept something like a latitude and longitude as doubles for example.