multiple styles within multigeometry?

358 views
Skip to first unread message

hwong1

unread,
Sep 29, 2006, 12:15:35 PM9/29/06
to KML Discussions
Is there a way to define different styles for different polygons within one multigeometry object?

tekgergedan

unread,
Sep 29, 2006, 12:24:36 PM9/29/06
to KML Discussions
Hi

I dont know any reason as to not being able to do that. Just create styles with ids and assign the ids to the polygons. It should work.

hwong1

unread,
Sep 29, 2006, 2:02:30 PM9/29/06
to KML Discussions
Am I able to do this in the same placemark though?

I have a few lines and polygons in the same multigeometry, which are in the same placemark. I want to make some of the polygons red and some of the other shapes a different color. According to the KML dictionary, the styleurl can only be contained by a Placemark.

When you say styles with id's do you mean different polystyles? like this:
Code:
 
<Style id="defaultstyle">
<LineStyle>
<color>ff00ffff</color>
<width>4.0</width>
</LineStyle>
<PolyStyle id="defaultpolystyle">
<color>ff00ffff</color>
<fill>1</fill>
</PolyStyle>
<PolyStyle id="fatalstyle">
<color>ff0000ff</color>
<fill>1</fill>
</PolyStyle>
<PolyStyle id="injurystyle">
<color>ff0000ff</color>
<fill>0</fill>
</PolyStyle>
</Style>



I tried referencing each polygon in my multigeometry in the following way:
Code:
 <Polygon>
<styleUrl>#fatalstyle</styleUrl>
.
.
.
</Polygon>


but the appropriate style doesnt show up

tekgergedan

unread,
Sep 29, 2006, 3:59:59 PM9/29/06
to KML Discussions
You seem correct. Polygons within one MultiGeometry seems unable to have different styles. That was something I've never tried and now I cant do it either.

Maybe you can overcome this using nesting MultiGeometrys. It seems from the documentary that nesting is possible but still the Polygons may share the same style.

regionator

unread,
Sep 30, 2006, 5:09:34 PM9/30/06
to KML Discussions

<Style> and <styleUrl> are elements of any Feature such as <Placemark>
(no Geometry has its own style directly and sub-styles are not individually referenced).

See the Feature and Geometry sections of the KML 2.1 Reference:

http://earth.google.com/kml/kml_tags_21.html#feature
http://earth.google.com/kml/kml_tags_21.html#geometry
http://earth.google.com/kml/kml_tags_21.html#placemark

If 2 <Polygon>'s are to have different <PolyStyle> create 2 <Style>'s
(preferrably in <Document>) each with an id and create 2 <Placemarks>
each with its own <Polygon>. Multiple <Polygon>'s of the same style
can be combined in a single <MultiGeometry> in a single <Placemark>.

tekgergedan

unread,
Oct 1, 2006, 6:43:28 AM10/1/06
to KML Discussions
So, using <Model> can be a partial solution though it is not aimed for this kind of use?
Reply all
Reply to author
Forward
0 new messages