skyline 添加图层
function LoadLayer()
{
var xmlLayerBaseInfo = "<PlugData>";
xmlLayerBaseInfo += "<PlugType>shape</PlugType>";
xmlLayerBaseInfo += "<LayerName>C:\\xxx.shp</LayerName>";//shape文件的地址或者图层的名称
xmlLayerBaseInfo += "<Server></Server>";//SDE或者WFS服务的地址
xmlLayerBaseInfo += "<Instance></Instance>";//SDE的端口号
xmlLayerBaseInfo += "<User></User>";
xmlLayerBaseInfo += "<Password></Password>";
xmlLayerBaseInfo += "<TableName></TableName>";//GeoDatabase中的表名称
xmlLayerBaseInfo += "<AttributesToLoad>XXX,YYY,ZZZ</AttributesToLoad>";//需要导入的属性
xmlLayerBaseInfo += "<Feature>1</Feature>";
xmlLayerBaseInfo += "<Annotation>1</Annotation>";
xmlLayerBaseInfo += "<SaveItems>1</SaveItems>";
xmlLayerBaseInfo += "<GroupKey></GroupKey>";
xmlLayerBaseInfo += "<SysKey></SysKey>";
xmlLayerBaseInfo += "<DatumKey></DatumKey>";
xmlLayerBaseInfo += "<UnitKey></UnitKey>";
xmlLayerBaseInfo += "<StreamedLayer>0</StreamedLayer>";
xmlLayerBaseInfo += "</PlugData>";
var player = IInformationTree.CreateLayer("XXX",xmlLayerBaseInfo,0);
player.SetValue("Text",0,"[XXX]");
player.SetValue("Scale",0,10000);
player.load();
}
注:非常重要的一点,加载图层用到的xmlLayerBaseInfo字符串对于大小写非常敏感,所以一定要按照上文的格式来写。