How to use Cascading Styles

50 views
Skip to first unread message

TJ1

unread,
Oct 28, 2005, 12:12:42 AM10/28/05
to KML Discussions
I was having some issues with styles cascading from the root document through various NetworkLinks.

When the root document loads and pulls in all the subsidiary NetworkLinks the styles defined in the root are applied correctly right up the tree to the final leaves.

However, once the NetworkLinks began their autonomous refresh cycles the styles from the root document were cancelled and all branches and leaves display using default styles The only way I could prevent it was to embed the style library in every linked document - which must cause a performance hit because the library is large, and is loaded (redundantly) into several branches.

I tried using Folder instead of Document as the base tag in the child/grandChild documents, thinking that the style selector would then reference the root styles, but it didn't seem to make any difference.

There's no clear documentation on how to construction style selectors for this kind of scenario either. However there are examples of using a fully qualified path selector of the form http://domain.com/some/folders/to/file.kml#styleID.

I finally discovered that the way to do it is provide a selector ID that is prefixed with the root document's file-name but no host or path information.


<styleUrl>root.kml#style1</styleUrl>

Overview of my document structure:
Code:
<Document id="root">
<Style id="style1"></Style>
<StyleMap id="style2"></StyleMap>
<NetworkLink id="childLink"></NetworkLink>
</Document>


child then has:
Code:
<Document id="child">
<NetworkLink id="grandChild1Link"></NetworkLink>
<Folder id="cFolder">
<NetworkLink id="grandChild2Link"></NetworkLink>
<NetworkLink id="grandChild3Link"></NetworkLink>
</Folder>
</Document>


and grandChild1 has:
Code:
<Document id="grandChild1">
<Folder id="gc1Folder1">
<Placemark id="gc1F1Child1">
<styleUrl>root.kml#style1</styleUrl>
</Placemark>
</Folder>
<Folder id="gc1Folder2">
<Placemark id="gc1F2Child1">
<styleUrl>root.kml#style2</styleUrl>
</Placemark>
</Folder>
<Folder id="gc1Folder3">
<Placemark id="gc1F3Child1">
<styleUrl>root.kml#style1</styleUrl>
</Placemark>
</Folder>
</Document>

Jason_Birch

unread,
Oct 28, 2005, 11:55:56 PM10/28/05
to KML Discussions
I'm wondering what would happen when the user moves the document into their My Places area.

Have you experimented with the FQDN method? If the source KML for the styles is only requested once per session instead of once per reference, it would be a good way of maintaining a single set of styles over multiple downloadable files.

Jason

mcshea98

unread,
Oct 29, 2005, 9:59:01 AM10/29/05
to KML Discussions
Amazing work TJ1!
Reply all
Reply to author
Forward
0 new messages