Google Groups Home
Help | Sign in
Message from discussion Extracting a div defined as CDATA in KML, using javascript?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
debaser  
View profile
 More options Oct 7 2008, 7:07 am
From: debaser <jamiebar...@gmail.com>
Date: Tue, 7 Oct 2008 04:07:31 -0700 (PDT)
Local: Tues, Oct 7 2008 7:07 am
Subject: Re: Extracting a div defined as CDATA in KML, using javascript?
Yeah, if it's Firefox right? Now to make a custom script to check
browser versions and other stuff just to extract a CDATA node. Yay.
Fun.

Thanks Andy

On Oct 6, 4:55 pm, Andy R <andy.ros...@bluewin.ch> wrote:

> Try ... childNodes[1].nodeValue;

> On 6 Okt., 12:24, debaser <jamiebar...@gmail.com> wrote:

> > Hi all,

> > I have a KML file which defines a description used for the infoWindow.
> > The description tag containsCDATAwhich defines a div to be used to
> > display in the infoWindow, e.g.:

> > <Placemark>
> >   ...
> >   <description><![CDATA[
> >   <div style="font-size:9pt;font-family:trebuchet
> > MS,verdana,sans;margin-top:2px;margin-left:2px;line-height:9pt;">
> >   <p>this is only a test</p>
> >   <p>of the emergency broadcast system</p>
> >   </div>
> >   ]]></description>
> > </Placemark>

> > My problem comes in now, that instead of using the built in GGeoXml
> > utility to show markers, I'm manually reading the data using
> > GDownloadUrl:

> > GDownloadUrl(mapDataKmlUrl, function(data, responseCode) {
> >       var kml = GXml.parse(data);
> >       doStuff(kml);
> >     });

> > ... where doStuff shows markers depending on the content defined in
> > the Placemarks. What I want to do now, is add an event to the marker
> > to display the same info window as would be shown before using the
> > GGeoXml utility, which would use the description'sCDATAto add a div
> > to the infoWindow:

> > GEvent.addListener(marker, "click", function() {
> >     var infoWindowContent =
> > retrieveDescriptionFromPlacemark(placemark);
> >     marker.openInfoWindowHtml(infoWindowContent);
> >   });

> > I tried the following:

> > function retrieveDescriptionFromPlacemark(placemark) {
> >   return placemark.getElementsByTagName("description")
> > [0].childNodes[0].nodeValue;

> > }

> > ... but it returns a blank string for that node. Any suggestions on
> > how to get the actual div content would be greatly appreciated.

> > Thanks,

> > James


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google