0

问题是我需要更改拉伸线边框的默认颜色和不透明度。这是来自 GE API的图像。

所以,我需要自定义线下的灰色“墙”。如何重新设计?谢谢。

4

2 回答 2

0

基本上,您需要为您的功能添加LineStyle样式并指定颜色。

多边形颜色指定填充颜色(在多边形区域内),线条颜色指定线条、环和多边形的线条边界。

可以在此处找到 GE API 的示例。 http://earth-api-samples.googlecode.com/svn/trunk/examples/linestring-style.html

要指定不透明度,您需要在aabbggrr格式的代码颜色中设置 alpha 值(FF=完全不透明度),如以下代码片段所示:

var lineStyle = placemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(lineStyle.getWidth() + 2);
lineStyle.getColor().set('6600ffff');  // aabbggrr format
于 2012-11-08T16:08:09.843 回答
0

所以,基本上挤压线的“边框”是一个多边形对象,应该分别设置样式。

下面是来自 GE API 的示例,其中增加了一行和一个新方法getPolyStyle(),它为“墙”添加了自定义样式:

// Create the placemark
var lineStringPlacemark = ge.createPlacemark('');

// Create the LineString; set it to extend down to the ground
// and set the altitude mode
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
lineString.setExtrude(true);
lineString.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);

// Add LineString points
lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
lineString.getCoordinates().pushLatLngAlt(48.764, -121.828, 700);
lineString.getCoordinates().pushLatLngAlt(48.776, -121.818, 700);
lineString.getCoordinates().pushLatLngAlt(48.787, -121.794, 700);
lineString.getCoordinates().pushLatLngAlt(48.781, -121.778, 700);
lineString.getCoordinates().pushLatLngAlt(48.771, -121.766, 700);
lineString.getCoordinates().pushLatLngAlt(48.757, -121.768, 700);
lineString.getCoordinates().pushLatLngAlt(48.747, -121.773, 700);

// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();

/*** STYLING THE POLYGON ('WALL') UNDER THE LINE ***/
lineStringPlacemark.getStyleSelector().getPolyStyle().getColor().set('9900ffff');
/***************************************************/

lineStyle.setWidth(5);
lineStyle.getColor().set('9900ffff');  // aabbggrr format

// Add the feature to Earth
ge.getFeatures().appendChild(lineStringPlacemark);
于 2012-11-11T15:55:25.790 回答