//load wms layer
DatasourceConnectionInfo sourceWmsinfo=new DatasourceConnectionInfo();
//
sourceWmsinfo.setAlias("livingcircle");//别名
//设置引擎类型
sourceWmsinfo.setEngineType(EngineType.Rest);
//sourceWmsinfo.setEngineType(EngineType.OGC);
//设置驱动名称
sourceWmsinfo.setDriver("WMS");
//设置地图服务地址
String urlWms ="http://192.168.1.4:9182/geoserver/test/wms";
sourceWmsinfo.setWebTransparent(true);
sourceWmsinfo.setWebFormat("image/png");
sourceWmsinfo.setReadOnly(false);
//sourceWmsinfo.setWebVisibleLayers("");//设置无效
sourceWmsinfo.setServer(urlWms);
//打开数据源
Datasource datasourceWms = mWorkspace.getDatasources().open(sourceWmsinfo);
//添加到地图窗口中
//datasourceWms.getConnectionInfo()
if(null!=datasourceWms&&null!=datasourceWms.getDatasets()&&datasourceWms.getDatasets().getCount()>0){
Dataset ds=datasourceWms.getDatasets().get(0);
Layer layer =mMapControl.getMap().getLayers().add(ds,true);
String ls=datasourceWms.getConnectionInfo().getWebVisibleLayers();
//layer.getParentGroup().get(0).setVisible(false);
LayerSettingImage lsi= (LayerSettingImage) layer.getAdditionalSetting();
lsi.setTransparent(true);
//lsi.setVisibleSubLayers(new String[]{""});
//layer.setAdditionalSetting(lsi);
mMapControl.getMap().refresh();
}