I'm having the exact same problem. The KML loads up great no problems
there, its pretty nice. Just can't access any of the properties
within...
the top chunk of the kml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns=\"
http://earth.google.com/kml/2.2\">
<Document id='game_data'>
<Style id='city'>
<IconStyle>
<color>ffffffff</color>
<scale>0.7</scale>
<Icon>
<href>images/city_icon.png</href>
</Icon>
</IconStyle>
...
placemarks...etc...
paths...etc...
...
here's code I'm using to try and access the properties:
function getCities() {
var features = ge.getGlobe().getFeatures().getChildNodes();
for(var i = 0; i < features.getLength(); i++) {
var feat = features.item(i);
alert(feat.getType() + '; ' + feat.getId());
}
}
the only element i can manage to pull up from getFeatures, alerts
"KmlDocument; game_data"
It seems identical for,
ge.getGlobe().getFeatures().getChildNodes();
ge.getFeatures().getChildNodes();
On Jun 11, 1:30 pm, fraser wrote:
> Hi,
>
> Yes the plug-in is ace, nice work!
>
> OK some history...
>
> I have been playing around with various ways of adding placemarks to
> Google earth.
>
> At the moment I have a MySQL database and I am generatingKMLfiles
> from this via PHP.
>
> See:
http://www.simpsonhaugh.co.uk/SimpsonHaugh/map/genMapKML.php
>
> I am then loading theKMLinto the plug-in using fetchKml. I then
> wanted to iterate through the place marks and maybe build a sidebar,
> etc. I tried using the a function based on the code in the second
> post. The thing is I just cant seem to get any of the KmlPlacemarks
> only the KmlDocument itself.
>
> The parseKml() function simply alerts
>
> "KmlDocument; SimpsonHaugh - Projects"
>
> See:
http://www.simpsonhaugh.co.uk/SimpsonHaugh/map/earth.php
>
> How would one iterate through the rest of theKMLto get at the
> placemarks?
>
> I tried loading theKMLvia a networklink with the same result...
>
> Any help would be great!
>
> Cheers,
>
> Fraser.
>
> On Jun 6, 9:03 am, marquies wrote:
>
> > You can add an unique event listener to each Placemark with
>
> > google.earth.addEventListener(p, "click", function() { /* do what I
> > want */ } );
>
> > Wether you fetch aKMLwith window.google.earth.fetchKml ,
> > ge.parseKml or create it manually, you can get allKML-Features with
> > ge.getGlobe().getFeatures(). You can iterate them and identify by name
> > or maybe id. You can get every attribute of them with a getter method
> > like getName(). What getter are aviable depends on the type of the
> > feature, consult API-Doc (
http://code.google.com/apis/earth/
> > documentation/API.html#KmlFeature)
>
> > var features = ge.getGlobe().getFeatures().getChildNodes();
> > for(var i = 0; i < features.getLength(); i++) {
> > var feat = features.item(i);
> > alert(feat.getType() + '; ' + feat.getName());
>
> > }
>
> > On 6 Jun., 02:12, rhoinkes wrote:
>
> > > Firstly, let me say that the Plugin is a great start and has the
> > > potential to give me the programmability of Google Earth that my apps
> > > really need (without getting into COM/Windows only).
>
> > > I have the plugin starting up and loading up myKMLwith lots of
> > > placemarks. I am trying to avoid infoWindow popups. I have an event
> > > handling the mouse click, detecting that it was on a placemark and
> > > doing the event.preventDefault(). All of that is fine.
>
> > > HOWEVER, I do need to call up information in a sep. IFRAME (or other
> > > entity on the page) based on the Placemark I click on. Previously
> > > (prior to GE Plugin) the user had to click Placemark->InfoWindow->WebBrowser which was 2 clicks to get to the full info. I am trying to
>
> > > limit this to 1 click Placemark->WebBrowser.
>
> > > I get theKmlPlacemarkfrom event.getCurrentTarget() but I can't seem
> > > to find any methods to get back properties of the placemark that might
> > > let me choose what to bring up in the IFRAME. Remember that these
> > > placemarks are in the loadedKMLfile, NOT made via Javascript.