gex getObjectById getFeatureById problem

39 views
Skip to first unread message

Berwyn

unread,
Jun 17, 2009, 7:54:12 PM6/17/09
to KML Developer Support - Google Earth Plug-in
Roman

thanks for the utility libraries, they are going to be a big help,
especially the polygon and line drawing tools.

I'm loading multiple server side generated kml's into a ge plugin and
tried using the getFeatureById code in the google io presentation you
had to check if a kml being loaded already had an instance. and if so
I would remove the old and add the new.

I also tried gex.dom.getObjectId

both had a ploblem starting the walk, the first element was tripping
things up with getId() for the first step in the walk.

I altered getFeatureById to ignore the first step and things seam to
work

function getFeatureById(id) {
var foundFeature = null;
var i = false ;
gex.dom.walk(function() {
if (i) {
if (this.getId() == id) {
foundFeature = this;
return false; // end the walk
}
} else
i = true;

});
return foundFeature;
}


initialy I had for the
if statement if( this.getString() != '[xpconnect wrapped native
prototype]' )


worked with firebox but nor chrome or IE

berwyn

Roman N

unread,
Jun 19, 2009, 5:31:07 PM6/19/09
to KML Developer Support - Google Earth Plug-in
Hi berwyn,

That's quite interesting... can you provide a sample KML file that was
showing the problem? The only way I can see that failing is if 'getId'
doesn't exist on the object, but fetchKml'd objects should always have
ID's. Can you try removing your 'if (i)' test and then changing

if (this.getId() == id) to if ('getId' in this && this.getId
() == id)

and seeing if that fixes it?

At any rate, I just pushed an update to the trunk of the SVN
repository that checks for existence of 'getId' before attempting to
call it. Hopefully that fixes it.

Thanks,
Roman

Berwyn

unread,
Jun 22, 2009, 2:14:22 PM6/22/09
to KML Developer Support - Google Earth Plug-in
Roman

The changes work, thanks.

Do you still want a sample of the kml?

I'm searching the gex dom sometimes before any kml has been loaded,
sometimes after some documents have been removed. The reson for the
search being, kml documents with the same id are loaded twice.

The kml isn't anything special, the Document has a name, id (which is
the id I'm searching for so that the kml isn't loaded twice), followed
by a couple of Styles and then a number of placemarks with timestamps.

Berwyn

Roman N

unread,
Jun 22, 2009, 2:57:29 PM6/22/09
to KML Developer Support - Google Earth Plug-in
Hi Berwyn,

Sure, if you can provide the KML file and exact code you're using to
traverse the DOM, that'd be really helpful. I'm unsure at what point
getId() would be failing (i.e. which API interface doesn't expose it).

No rush, though. Thanks for your help :)

Roman

Berwyn

unread,
Jun 25, 2009, 3:51:33 PM6/25/09
to KML Developer Support - Google Earth Plug-in
Roman

Is there any way to send you a link in private to the page.

Berwyn

Berwyn

unread,
Jun 25, 2009, 3:57:53 PM6/25/09
to KML Developer Support - Google Earth Plug-in
Roman

Are you the owner for the group: Google Earth API Notify

I can send the info that way.

Berwyn

Roman N

unread,
Jun 28, 2009, 1:08:40 AM6/28/09
to KML Developer Support - Google Earth Plug-in
Hi Berwyn,

I'll send you a private email shortly. Thanks!

Roman
Reply all
Reply to author
Forward
0 new messages