Remove Screen Overlay

431 views
Skip to first unread message

kdd

unread,
Jul 6, 2008, 10:35:00 PM7/6/08
to KML Developer Support - Google Earth Browser Plugin
How can I remove screen overlay?

ge.getFeatures().removeChild( itemToRemove ); works, but when I want
to remove multiple overlays, calling removeChild with multiple
instances of "objects" does NOT work. It just doesn't make them go
away.

My code is like:
ge.getFeatures().removeChild ( x );
ge.getFeatures().removeChild ( y );
ge.getFeatures().removeChild ( z );

That only removes just 1 overlay, not all 3.

Thanks.

K.

Roman N

unread,
Jul 8, 2008, 8:42:41 PM7/8/08
to KML Developer Support - Google Earth Browser Plugin
K,

Could you provide some more context--maybe an example page that shows
the behavior?

- Roman

Benjamin M Brown

unread,
Jul 15, 2008, 5:24:09 AM7/15/08
to KML Developer Support - Google Earth Browser Plugin
Same issue here.. I have multiple overlays in an animation sequence
and would like to clear everything when each pass of our animation
routine begins. Is there a quick/easy "removeAllOverlays" function?


On Jul 8, 7:42 pm, Roman N wrote:
> K,
>
> Could you provide some more context--maybe an example page that shows
> the behavior?
>
> - Roman
>
> On Jul 6, 7:35 pm, kdd wrote:
>
> > How can I remove screen overlay?
>
> > ge.getFeatures().removeChild( itemToRemove ); works, but when I want
> > to remove multipleoverlays, calling removeChild with multiple

fraser

unread,
Jul 15, 2008, 6:42:02 AM7/15/08
to KML Developer Support - Google Earth Browser Plugin
Hey,

I might be wrong and it might not be the same thing going on but I
don't think you can fully remove loaded kml/kmz files, only hide them.
I think this is due to how the Javascript garbage collector works...

You could try...

x.setVisibility(false);
y.setVisibility(false);
z.setVisibility(false);


If you think it's the same issue maybe see these threads:
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/e83a6cc46f22942/cdde2f0ef944b8b8?hl=en&lnk=gst&q=garbage#cdde2f0ef944b8b8
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/dbd3b04deb2be76d/be36f6859efe05ca?hl=en&lnk=gst&q=remove+kml%23%5D#be36f6859efe05ca
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/dda0b1e1c0e24258/89f2a0a795be54d3?hl=en&lnk=gst&q=remove#89f2a0a795be54d3

Regards,

Fraser.
> > > K.- Hide quoted text -
>
> - Show quoted text -

Roman N

unread,
Jul 15, 2008, 12:53:24 PM7/15/08
to KML Developer Support - Google Earth Browser Plugin
The concepts are related; Fraser's first link points to a great thread
(http://groups.google.com/group/google-earth-browser-plugin/
browse_thread/thread/e83a6cc46f22942/cdde2f0ef944b8b8?
hl=en&lnk=gst&q=garbage#cdde2f0ef944b8b8) that has a good code example
explaining the add/remove child behavior and consequences.

Although one should be able to removeChild() any existing placemarks
without a problem, they aren't actually deleted from memory until the
JavaScript garbage collector chooses to do so. This prevents, for
example, creating placemarks with the same ID as a previously removed
placemark.

Because this is a tricky subject, it's best to examine the code in its
entirety to determine the cause of the unexpected behavior.

**Benjamin-- the best way to remove all overlays is simple iterate
through them like so:

var c = ge.getFeatures().getFirstChild();
while (c) {
var s = c.getNextSibling();
ge.getFeatures().removeChild(c);
c = s;
}

**K-- if you're still having this problem, feel free to post an
example link or larger code snippet so that we can help you
troubleshoot.

- Roman

Benjamin M Brown

unread,
Jul 17, 2008, 4:55:38 AM7/17/08
to KML Developer Support - Google Earth Browser Plugin
Roman, thanks for that code snippet... works like a charm! That was
what I had in my head but couldn't put translate to this API ;)

Hopefully I'll be able to post the results of my work (an everyone's
help) here soon.

Hint: *up-to-date animated weather radar ;)

-b^2


On Jul 15, 11:53 am, Roman N wrote:
> The concepts are related; Fraser's first link points to a great thread
> (http://groups.google.com/group/google-earth-browser-plugin/
> browse_thread/thread/e83a6cc46f22942/cdde2f0ef944b8b8?
> hl=en&lnk=gst&q=garbage#cdde2f0ef944b8b8) that has a good code example
> explaining the add/removechild behavior and consequences.
>
> Although one should be able to removeChild() any existing placemarks
> without a problem, they aren't actually deleted from memory until the
> JavaScript garbage collector chooses to do so. This prevents, for
> example, creating placemarks with the same ID as a previously removed
> placemark.
>
> Because this is a tricky subject, it's best to examine the code in its
> entirety to determine the cause of the unexpected behavior.
>
> **Benjamin-- the best way toremovealloverlaysis simple iterate

Roman N

unread,
Jul 17, 2008, 12:51:44 PM7/17/08
to KML Developer Support - Google Earth Browser Plugin
Great--I'm looking forward to it!

- Roman
Reply all
Reply to author
Forward
0 new messages