How to remove a KML file?

1,329 views
Skip to first unread message

thematicmapping.org

unread,
Jun 4, 2008, 8:15:36 PM6/4/08
to KML Developer Support - Google Earth Browser Plugin
Hi,

I'm using this code to overlay a KML file on GE:

var networkLink = gePreview.createNetworkLink("");
networkLink.setFlyToView(true);
var link = gePreview.createLink("");
link.setHref(kmzlink);
networkLink.setLink(link);
gePreview.getFeatures().replaceChild(networkLink);

In my script I need to remove this KML file before I load a new file.
How can I remove a KML file already added?

Thanks,
Bjorn

marquies

unread,
Jun 5, 2008, 3:04:25 AM6/5/08
to KML Developer Support - Google Earth Browser Plugin
Hi Bjorn,

check this code:

var networkLink = ge.createNetworkLink("");
networkLink.setFlyToView(true);
var link = ge.createLink("");
link.setHref('doc.kml');
networkLink.setLink(link);

ge.getGlobe().getFeatures().appendChild(networkLink);

// This removes the KML
ge.getGlobe().getFeatures().removeChild(networkLink);

thematicmapping.org

unread,
Jun 5, 2008, 6:16:56 PM6/5/08
to KML Developer Support - Google Earth Browser Plugin
Thanks marquies!

It works
> > Bjorn- Hide quoted text -
>
> - Show quoted text -

Blair

unread,
Jun 6, 2008, 7:54:08 PM6/6/08
to KML Developer Support - Google Earth Browser Plugin
Hi Marquies,

I was able to make this work but it appears that the KML layers do not
completely remove. For example it appears that parts of the KML
remain referenced in memory by the globe. This happens when I remove
the KML and add a new KML. Have you seen this? Is this a bug? Is
there a way to clear all KML globally? Thanks again.

Cheers,
Blair

marquies

unread,
Jun 7, 2008, 7:47:27 AM6/7/08
to KML Developer Support - Google Earth Browser Plugin
Hi Blair,

can you provide some demo code? What browser and version do you use?

If you remove the feature and set the reference to null it will be
removed on the next call of the garbage collector. But this should
have no effect to the GE Plug, if you remove it, it should be removed.
All methods for the feature container are described here:

http://code.google.com/apis/earth/documentation/API.html#GESchemaObjectContainer

marquies
www.GONICUS.de
Message has been deleted
Message has been deleted

fraser

unread,
Jun 15, 2008, 12:09:29 PM6/15/08
to KML Developer Support - Google Earth Browser Plugin
Hi all,

I have the same problem as Blair. I can load a new KML file but the
old placemarks are not removed when removeChild() is called...

ge.getGlobe().getFeatures().removeChild(currentKml);

I have also tried...

var fc = ge.getGlobe().getFeatures().getFirstChild();
ge.getGlobe().getFeatures().removeChild(fc);

Check:

http://www.simpsonhaugh.co.uk/SimpsonHaugh/map/earth.php

If you click on any of the links...

Type | City | Name | Date | Status

You will notice the placemarks look like they have been removed when
the link is clicked.
And the new data is loaded (same placemarks in different folders)

However if you check by clicking a placemark you see in fact a
duplicate has been made.
In fact a duplicate is added every time the links are clicked...

I noticed people having the same issue with networklinks although I
happen to be using google.earth.fetchKml.

Is this a bug or somthing?

Regards,

Fraser.

On Jun 7, 12:47 pm, marquies wrote:
> Hi Blair,
>
> can you provide some demo code? What browser and version do you use?
>
> If youremovethe feature and set the reference to null it will be
> removed on the next call of the garbage collector. But this should
> have no effect to the GE Plug, if youremoveit, it should be removed.
> All methods for the feature container are described here:
>
> http://code.google.com/apis/earth/documentation/API.html#GESchemaObje...
>
> marquieswww.GONICUS.de
>
> On 7 Jun., 01:54, Blair wrote:
>
>
>
> > Hi Marquies,
>
> > I was able to make this work but it appears that the KML layers do not
> > completelyremove.  For example it appears that parts of the KML
> > > > In my script I need toremovethis KML file before I load a new file.
> > > > How can Iremovea KML file already added?
>
> > > > Thanks,
> > > > Bjorn- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -

jpwade_bsu

unread,
Jun 15, 2008, 10:50:44 PM6/15/08
to KML Developer Support - Google Earth Browser Plugin
James Stafford @ barnabu.co.uk posted an example using setVisibility:
full html
http://www.barnabu.co.uk/ge-plugin/

a few quirks added here:
http://www.czmartin.com/jpw/asp_arcmap/gem_3d_netlink_multiples.html


jpwade
www.czmartin.com/jpw

fraser

unread,
Jun 15, 2008, 11:17:11 PM6/15/08
to KML Developer Support - Google Earth Browser Plugin
Hmmm,

I neither using networklinks nor setViibility...

I'm using fetchKml and removeChild.

Check this page please I'm pretty sure there is a bug.

http://www.simpsonhaugh.com/SimpsonHaugh/map/fetchKml_bug.html

...


On Jun 16, 3:50 am, jpwade_bsu wrote:
> James Stafford @ barnabu.co.uk posted an example using setVisibility:
> full htmlhttp://www.barnabu.co.uk/ge-plugin/
Reply all
Reply to author
Forward
0 new messages