I read the previous discussion on this, but I'm still confused about how to get the kml variable

10 views
Skip to first unread message

dmgreer

unread,
Nov 25, 2008, 2:12:31 AM11/25/08
to KML Developer Support - Google Earth Browser Plugin
In a previous discussion, Roman wrote

fraser,

You should be able to use the getFeatures() method on the 'kml'
variable just as you would with the 'ge' variable, i.e.:

var firstChildInKml = kml.getFeatures().getFirstChild();

From there you could traverse the object model as needed.

- Roman

I've tried this and other suggestions here every which way, but I'm
still unable to traverse the kml tree. All I want to do is get to the
placemark that's been loaded with my kml. When I try fraser's method
of iterating through the kml dom, I get blocked by errors like
"getFeature not supported".

When I use

var features = ge.getGlobe().getFeatures().getChildNodes();

all I get is my overlay and my document.

How do I get to that kml variable? I've burned through a lot of dead
ends on that one too.

fraser

unread,
Nov 25, 2008, 12:11:57 PM11/25/08
to KML Developer Support - Google Earth Browser Plugin
Hi dmgreer,

Can I ask - are you loading the kml via a network link or fetchKml?
I ask because there are a few caveats to networks that could be the
cause of your problems.

F.

dmgreer

unread,
Nov 25, 2008, 6:51:34 PM11/25/08
to KML Developer Support - Google Earth Browser Plugin
It's fetchKml. There are network links inside the kml that's fetched,
but that's probably not what you're asking.

Dale

fraser

unread,
Nov 25, 2008, 7:42:30 PM11/25/08
to KML Developer Support - Google Earth Browser Plugin
Hi,

That could be it - are the placemarks you are trying to access loaded
via the networklinks inside the kml?
The reason being that networklinks are a bit of a 'dead end' when it
come to traversing the object model.

If this is the case is then read this thread:
http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/bd1f4deeccc8d95c/0c6ab1982c467569?lnk=gst&q=
as it explains how to get at the kml data that is loaded by the
networkink.

If this doesn't sound like the right thing then could you post an
example of a page? Or the kml file you are trying to traverse?
It is much easier to help if one can see directly what is happening!

Regards,

F.
> > > ends on that one too.- Hide quoted text -
>
> - Show quoted text -

dmgreer

unread,
Nov 25, 2008, 8:22:30 PM11/25/08
to KML Developer Support - Google Earth Browser Plugin
The placemark isn't coming in through the networklink. Here's my kml:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document id="3dskimaps">
<name>3dSkiMaps Ski Resorts</name>
<Style id="skiIcon_1">
<IconStyle id="skiIcon_2">
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/ski.png</
href>
</Icon>
</IconStyle>
</Style>
<Style id="hideChildren">
<ListStyle>
<listItemType>checkHideChildren</listItemType>
</ListStyle>
</Style>
<Folder>
<name>Alpine Meadows Ski Resort</name>
<Placemark>
<name>Alpine Meadows Ski Resort</name>
<LookAt>
<longitude>-120.23678</longitude>
<latitude>39.159099</latitude>
<range>2985</range>
<tilt>41</tilt>
<heading>179</heading>
<altitudeMode>relativeToGround</altitudeMode>
</LookAt>
<Snippet>
<![CDATA[
<a href="http://3dskimaps.com/alpinemeadows">
At 3dSkiMaps.com.
</a>
<a href="http://www.skialpine.com/" target="_blank">Official
URL</a>
]]>
</Snippet>
<description>
<![CDATA[
<table><tr><td>
<div><h3>Ski Your Best&trade; with 3dSkiMaps</h3>
<table><tr></tr></table>
</div>
<a href="http://www.skialpine.com/" target="_blank">Official
URL for Alpine Meadows Ski Resort</a>
</td></tr></table>
]]>
</description>
<Point>
<coordinates>-120.236778, 39.16629,0</coordinates>
</Point>
<styleUrl>#skiIcon_1</styleUrl>
</Placemark><Folder><Folder>
<name>alpinemeadows_superoverlay</name>
<Region>
<Lod>
<minLodPixels>85.3333333333</minLodPixels><maxLodPixels>-1</
maxLodPixels>
<minFadeExtent>170.666666667</minFadeExtent>
<maxFadeExtent>170.666666667</maxFadeExtent>
</Lod>
<LatLonAltBox>
<north>39.17</north><south>39.14</south>
<east>-120.216091116</east><west>-120.256</west>
</LatLonAltBox>
</Region><NetworkLink>
<name>nw_100</name>
<Region>
<Lod>
<minLodPixels>85.3333333333</minLodPixels><maxLodPixels>-1</
maxLodPixels>
<minFadeExtent>170.666666667</minFadeExtent>
<maxFadeExtent>170.666666667</maxFadeExtent>
</Lod>
<LatLonAltBox>
<north>39.1581132075</north><south>39.14</south>
<east>-120.216091116</east><west>-120.239416856</west>
</LatLonAltBox>
</Region>
<Link>
<href>http://3dskimaps.com/ge/region.php</href>
<httpQuery>path=alpinemeadows&amp;level=1&amp;i=0&amp;j=0</
httpQuery>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewFormat/>
</Link>
</NetworkLink><NetworkLink>
<name>nw_101</name>
<Region>
<Lod>
<minLodPixels>85.3333333333</minLodPixels><maxLodPixels>-1</
maxLodPixels>
<minFadeExtent>170.666666667</minFadeExtent>
<maxFadeExtent>170.666666667</maxFadeExtent>
</Lod>
<LatLonAltBox>
<north>39.1762264151</north><south>39.1581132075</south>
<east>-120.216091116</east><west>-120.239416856</west>
</LatLonAltBox>
</Region>
<Link>
<href>http://3dskimaps.com/ge/region.php</href>
<httpQuery>path=alpinemeadows&amp;level=1&amp;i=0&amp;j=1</
httpQuery>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewFormat/>
</Link>
</NetworkLink><NetworkLink>
<name>nw_110</name>
<Region>
<Lod>
<minLodPixels>85.3333333333</minLodPixels><maxLodPixels>-1</
maxLodPixels>
<minFadeExtent>170.666666667</minFadeExtent>
<maxFadeExtent>170.666666667</maxFadeExtent>
</Lod>
<LatLonAltBox>
<north>39.1581132075</north><south>39.14</south>
<east>-120.239416856</east><west>-120.262742597</west>
</LatLonAltBox>
</Region>
<Link>
<href>http://3dskimaps.com/ge/region.php</href>
<httpQuery>path=alpinemeadows&amp;level=1&amp;i=1&amp;j=0</
httpQuery>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewFormat/>
</Link>
</NetworkLink><NetworkLink>
<name>nw_111</name>
<Region>
<Lod>
<minLodPixels>85.3333333333</minLodPixels><maxLodPixels>-1</
maxLodPixels>
<minFadeExtent>170.666666667</minFadeExtent>
<maxFadeExtent>170.666666667</maxFadeExtent>
</Lod>
<LatLonAltBox>
<north>39.1762264151</north><south>39.1581132075</south>
<east>-120.239416856</east><west>-120.262742597</west>
</LatLonAltBox>
</Region>
<Link>
<href>http://3dskimaps.com/ge/region.php</href>
<httpQuery>path=alpinemeadows&amp;level=1&amp;i=1&amp;j=1</
httpQuery>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewFormat/>
</Link>
</NetworkLink>
<GroundOverlay>
<color>2fffffff</color>
<drawOrder>0</drawOrder>
<Icon>
<href>http://3dskimaps.com/alpinemeadows/overlayr/
TileGroup0/0-0-0.jpg</href>
</Icon>
<LatLonBox>
<north>39.17</north><south>39.14</south>
<east>-120.216091116</east><west>-120.256</west>
</LatLonBox>
</GroundOverlay>
</Folder><styleUrl>#hideChildren</styleUrl></Folder></Folder></
Document>
</kml>


On Nov 25, 6:42 pm, fraser wrote:
> Hi,
>
> That could be it - are the placemarks you are trying to access loaded
> via the networklinks inside the kml?
> The reason being that networklinks are a bit of a 'dead end' when it
> come to traversing the object model.
>
> If this is the case is then read this thread:http://groups.google.com/group/google-earth-browser-plugin/browse_thr...

dmgreer

unread,
Nov 26, 2008, 12:18:51 AM11/26/08
to KML Developer Support - Google Earth Browser Plugin
Hang on, I found it. I had a Folder without a name inside my main
Folder, so when traverseKml went through on the second recursion it
blew up on node.getName() and returned nothing. I took that folder out
and now I'm getting back the KmlFolder and the KmlPlacemark node,
which is what I was looking for.

Thanks for listening, anyway.

Dale

On Nov 25, 6:42 pm, fraser wrote:
> Hi,
>
> That could be it - are the placemarks you are trying to access loaded
> via the networklinks inside the kml?
> The reason being that networklinks are a bit of a 'dead end' when it
> come to traversing the object model.
>
> If this is the case is then read this thread:http://groups.google.com/group/google-earth-browser-plugin/browse_thr...
Reply all
Reply to author
Forward
0 new messages