
昨天用WorldWind.NET试图添加KML Marker,试了很多次都没有成功,火了,索性自己实现。不过自己实现就不用KML了,直接用GeoTools读Shapefile,把坐标读出来,做成一个UserFacingIcon,添加到IconLayer。
protected void makeIcons(){
final Font font = new Font("Verdana", Font.PLAIN, 9);
FeatureIterator i = features.features();
while(i.hasNext()){
Feature f = i.next();
double lon = f.getDefaultGeometry().getCoordinate().x;
double lat = f.getDefaultGeometry().getCoordinate().y;
LatLon lonlat = new LatLon(
Angle.fromDegreesLatitude(lat), Angle.fromDegreesLongitude(lon));
Position p = new Position(lonlat, 0);
final String iconPath = "3.png";
UserFacingIcon icon = new UserFacingIcon(iconPath ,p);
icon.setAlwaysOnTop(false);
icon.setShowToolTip(true);
icon.setToolTipText((String)f.getAttribute("PINYIN"));
icon.setToolTipFont(font);
iconLayer.addIcon(icon);
}
i.close();
}
再贴一些图吧:

这是垂直方向夸张设置为40倍的效果,看起来有点搞笑

这是10倍的效果:

江浙地区地形平台,没有什么震撼力,太原周边的情况就不同了,如果下面的图片效果不好可以点进又拍看原始图片,很震撼。

