Super Overlay transparency control

245 views
Skip to first unread message

BrianT

unread,
Jun 25, 2008, 7:52:09 PM6/25/08
to KML Developer Support - Google Earth Browser Plugin

First, we're very impressed with the capability of the plugin to
handle large datasets, especially in comparison to other browser-based
options.

Someone already posted asking about controlling transparency. Now I
can see how you would control the transparency of a single
<GroundOverlay>. However the more common use case for us is to stream
large numbers of tiles by <Region>. As you know, with the full GE
client, the transparency slider works at the "Layer" level, but it is
unclear to me whether with the current API transparency can be somehow
be propagated to all of the tiles within a hierarchy of Regions.

Having developed Google Earth layers for clients since the Keyhole
days, I can say that the transparency slider is a hugely popular
feature: anything you can do to make it programatically accessible
would be appreciated.


Thanks,

Brian

bFlood

unread,
Jun 26, 2008, 8:59:52 AM6/26/08
to KML Developer Support - Google Earth Browser Plugin
hey BT

agreed. an optimized folder transparency setting would be great. I've
noticed when looping through feature collections and changing visual
styles, it can happen instantly or there will be a "popping" effect as
each feature changes. I guess it's related to the rendering loop..

anyways, here's how you can change the transparency for an entire
folder:

var myFolder;
setFolderTransparency(myFolder, 50); //50 percent transparent


function setFolderTransparency(folder, percent)
{
//sanity check
if (percent < 0){percent = 0;}
if (percent > 100){percent = 100;}

var cnt = folder.getFeatures().getChildNodes().getLength();
for (var i=0; i<cnt; i++)
{
var f = folder.getFeatures().getChildNodes().item(i);
if (f.getType() == "KmlPlacemark")
{
var style = f.getStyleSelector();
if (style.getPolyStyle())
{
setColorTransparency(style.getPolyStyle().getColor(),
percent);
}
if (style.getLineStyle())
{
setColorTransparency(style.getLineStyle().getColor(),
percent);
}

}
else if (f.getType() == "KmlGroundOverlay")
{
setColorTransparency(f.getColor(), percent);
}

}

}


function setColorTransparency(color, percent)
{
var alpha = Math.round(Math.abs(((percent *
(255/100))-255))).toString(16);
var newColor = alpha + color.get().substr(2);
color.set(newColor);
Reply all
Reply to author
Forward
0 new messages