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?
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.