Extrusion Color (Other Than Gray)

201 views
Skip to first unread message

Oraxia

unread,
Nov 19, 2009, 5:51:13 PM11/19/09
to KML Developer Support - Google Earth Plug-in
The extrusion example right here shows a colored line with gray panels
as the extrusion down to Earth:
http://code.google.com/apis/earth/documentation/geometries.html

Is there a way to change the color (and possibly the transparency) of
the gray extrusion panels? Or is opaque gray the only color that comes
in?

Matthew J Reines

unread,
Nov 19, 2009, 6:25:19 PM11/19/09
to KML Developer Support - Google Earth Plug-in
Yes, although I'm not sure of the color extrusion should take on the
transparency of the Fill.A value.

Oraxia

unread,
Nov 19, 2009, 6:52:46 PM11/19/09
to KML Developer Support - Google Earth Plug-in
Okay, I guess I made a blunder with my original question--I should
have asked HOW :/ I probably also should have mentioned that I'm very,
very new to this, which is why I'm asking such lame questions. I
didn't see a fill color attribute on KmlLineStyle, so how would I set
a "fill" color?

Matthew J Reines

unread,
Nov 20, 2009, 5:21:11 AM11/20/09
to KML Developer Support - Google Earth Plug-in
Here's a (JavaScript) snippet:

//Create a style and set width and color of line
polygonPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = polygonPlacemark.getStyleSelector().getLineStyle
();
lineStyle.setWidth(5);
lineStyle.getColor().set('9900ffff');
var polyStyle = polygonPlacemark.getStyleSelector().getPolyStyle
();
polyStyle.setFill(1);
polyStyle.getColor().set('77555555');

When I draw a polygon after setting it up with this code, the
'extruded' color is grey and semi-transparent. I believe this would
also set color if you wanted something other than grey.

Hope that helps.

Oraxia

unread,
Nov 20, 2009, 1:15:45 PM11/20/09
to KML Developer Support - Google Earth Plug-in
Polygons have fill, and I've been able to do that, but what if my
extruded line is... just an extruded line? I'm talking about the grey
panels under the line, not some area in the middle of a polygon... Or
am I misreading the code snippet and somehow I can give a line a
KmlPolyStyle? Thanks!

Matthew J Reines

unread,
Nov 21, 2009, 9:02:29 AM11/21/09
to KML Developer Support - Google Earth Plug-in
Oraxia,

This code works for both lines and polygons. If the 'polygonPlacemark'
was a 'lineStringPlacemark' the same code will work.

I run this code (snippet) for linestrings and polylines the 'ikp'
variable can either be a polygon or linestring placemark.


ikp.setStyleSelector(_ge.GetPlugin().createStyle(""));
var style = ikp.getStyleSelector() as IKmlStyle;


IKmlLineStyle lineStyle = style.getLineStyle();

if (attributes.BorderStyle == LineStyle.Thick ||
attributes.BorderStyle == LineStyle.Chain ||
attributes.BorderStyle == LineStyle.ZigZag )
{
lineStyle.setWidth(5);
}
else
{
lineStyle.setWidth(2);
}

lineStyle.getColor().setA(attributes.BorderColor.A);
lineStyle.getColor().setR(attributes.BorderColor.R);
lineStyle.getColor().setG(attributes.BorderColor.G);
lineStyle.getColor().setB(attributes.BorderColor.B);

style.getPolyStyle().setFill(1);
style.getPolyStyle().setOutline(1);
style.getPolyStyle().getColor().setA
(attributes.FillColor.A);
style.getPolyStyle().getColor().setR
(attributes.FillColor.R);
style.getPolyStyle().getColor().setG
(attributes.FillColor.G);
style.getPolyStyle().getColor().setB
(attributes.FillColor.B);

Oraxia

unread,
Nov 21, 2009, 5:23:36 PM11/21/09
to KML Developer Support - Google Earth Plug-in
Thank you!
Reply all
Reply to author
Forward
0 new messages