IMap map = null; //跟map同一层次的activeView对象,他们都是“地图”的对象,map管理地图内容,activeView管理显示内容 IActiveView activeView = map as IActiveView; //获取当前地图显示范围 IEnvelope extent = activeView.Extent; //设置当前地图显示范围,相当于用代码实现缩放到某个范围 activeView.Extent = extent; //获取地图全图范围 //地图浏览功能中的全图,他的范围就是这样获取 IEnvelope fullExtent = activeView.FullExtent; //获取地图比例尺,同时可同于设置比例尺 double mapScale = map.MapScale; //获取和设置地图单位 esriUnits unit = map.MapUnits; //获取和设置地图的显示单位 esriUnits unit2 = map.DistanceUnits; //刷新地图 activeView.Refresh(); //屏幕长度(单位是像素)转地图实际长度 double mapLength = MapHelper.PixelsToMapUnits(activeView, 5); //获取Map的所有FeatureLayer List<IFeatureLayer> lstFeatureLayer = MapHelper.GetAllFeatureLayerInMap(map); if (1 == 2) { //在Map中通过真实表名获取图层,对于sde的表名不能带用户名 IFeatureLayer featureLayer = MapHelper.GetFeatureLayerByDatasetName(map, "roadLine"); } foreach (IFeatureLayer featureLayer in lstFeatureLayer) { //图层相关说明 //IFeatureLayer代表矢量图层,而ILayer代表图层,也是所有类型图层接口都实现了ILayer,因此IFeatureLayer可以as到ILayer ILayer layer = featureLayer as ILayer; //获取和设置图层的可视状态(就是图层树界面里图层左边的checkbox) bool visible = layer.Visible; //获取或设置图层名称 string name = layer.Name; //通过图层获取featureClass,是获取featureClass的方法之一。另一种方法是通过workspace获取 //注意IFeatureLayer和IFeatureClass是两个东西,虽然平时会都叫“图层”。IFeatureClass是指物理表,而IFeatureLayer指物理表加载到地图上形成的图层,前者更多指数据,后者只图层在地图的展示设置,如样式,标注等 IFeatureClass featureClass = featureLayer.FeatureClass; }