如果使用的资源类型是com.esri.adf.web.ags.data.AGSLocalMapResource,就可以在该资源上动态添加新的图层,图层数据可以来自不同的地方,比如本地的shapefile、file geodatabase或者SDE,也可以来自WMS等web服务。本文以本地的file geodatabase为例,为AGSLocalMapResource动态添加一个新的图层。

 

      首先,要得到地图的IMap接口才能对地图的图层进行操作。

// 得到本地MapResource
); 
   3:  
//得到targetMap
   5: MapServer mapServer = res.getLocalMapServer(); 
   6: IMap map = mapServer.getMap(mapServer.getDefaultMapName()); 
   7:  
//TODO:得到fLayer
   9:  
//添加图层至map
  11: map.addLayer(fLayer);

相关文章: