Skip To Content

MapLayer.Get (.NET)

此方法将返回由地图索引编号引用的指定地图或影像图层的地图或影像图层属性。

声明

public Dictionary<string, object> Esri.ArcGISForAutoCAD.MapLayer.Get(Document doc, int mapLayerId)

参数

类型名称描述必填

文档

doc

要进行操作的 AutoCAD 文档。

必填

int

mapLayerId

可以使用 MapLayer.Names 获取的与图层相关联的整型索引编号。

必填

返回

类型描述

Dictionary<string, object>

地图或影像图层属性的字典。 这些属性将根据服务而有所不同。 下表描述了字典的键和值。

该字典可能包含以下值和其他值:

类型值描述

"Allow_Raster_Function"

bool

图层是否支持栅格函数。

"Dynamic"

bool

当视图更改时,用于更新地图图层的方法(true = 动态,false = 刷新)。

"DatumTransformations"

IEnumerable<Dictionary<string, object>>

包含基准面变换步骤的字典集合。

"Id"

int

与图层相关联的整型索引编号。

"IsConnected"

bool

是否已连接图层。

"Name"

string

地图或影像图层的名称。

"ProcessingTemplate"

string

影像图层处理模板名称。

"ProcessingTemplateNames"

IEnumerable<string>

可用影像图层处理模板名称的集合。

"SpatialReference"

string

WKID 或 WKT 字符串形式的图层空间参考。

"Transparency"

int

已应用于地图的图像透明度百分比(0-99,0 表示不透明)。

"Visible"

bool

地图的可见性(true = 可见,false = 隐藏)

错误条件备注

如果参数无效,则此方法可能会抛出异常或者返回 null

示例 1

打印索引 1 地图图层的地图图层属性。

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var mapLayerId = 1;

// Get the map layer properties 
var mapLayerProperties = Esri.ArcGISForAutoCAD.MapLayer.Get(doc, mapLayerId);

// Print the map layer properties 
foreach (var property in mapLayerProperties)
{
  if (property.Key == "DatumTransformations")
  {
    doc.Editor.WriteMessage("\n{0}: ", property.Key);
    foreach (var value in property.Value as IEnumerable<Dictionary<string, object>>)
    {
      doc.Editor.WriteMessage("\nFrom {0}: To {1}", value["From"], value["To"]);
      doc.Editor.WriteMessage("\nTransformation:");
      foreach (var dict in value["Steps"] as List<Dictionary<string, object>>)
      {
        foreach (var kvp in dict)
        {
          doc.Editor.WriteMessage("\n\t{0}: {1}", kvp.Key, kvp.Value);
        }
      }
    }
    continue;
  }
  doc.Editor.WriteMessage("\n{0}: {1}", property.Key, property.Value);
}

/* Example output 
Id: 1
Name: ThreeLayers
ItemType: MapImageServiceLayer
IsConnected: True
ServiceUri: https://cadserver.esri.com/server/rest/services/afaHarness/ThreeLayers/MapServer
SpatialReference: 3857
Sublayer_0_Name: myGroupOfLayers
Sublayer_0_Visible: True
Sublayer_1_Name: ETH_ThreeLayers_6543
Sublayer_1_Visible: True
Sublayer_1_SourceSpRef: 103122
Sublayer_2_Name: ETH_ThreeLayers_2882
Sublayer_2_Visible: True
Sublayer_2_SourceSpRef: 2882
Sublayer_3_Name: ETH_ThreeLayers_6425
Sublayer_3_Visible: True
Sublayer_3_SourceSpRef: 103002
Visible: True
Transparency: 30
Dynamic: True
DatumTransformations:
From 6543: To 3857
Transformation:  
 Direction: Reverse
 Step: 108354
From 2882: To 3857
Transformation:
 Direction: Forward
 Step: 1901
*/

示例 2

打印索引 2 影像图层的影像图层属性。

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var layerId = 2;

// Get the imagery layer properties 
var imageryLayerProperties = Esri.ArcGISForAutoCAD.MapLayer.Get(doc, layerId);

// Print the imagery layer properties 
foreach (var property in imageryLayerProperties)
{
  if (property.Key == "ProcessingTemplateNames")
  {
    doc.Editor.WriteMessage("\n{0}:", property.Key);
    foreach (var value in property.Value as List<string>)
    {
      doc.Editor.WriteMessage(" " + value);
    }
    continue;
  }
  doc.Editor.WriteMessage("\n{0}: {1} ", property.Key, property.Value);
}

/* Example output 
Id: 2
Name: CharlotteLAS
ItemType: RasterServiceLayer
IsConnected: True
ServiceUri: https://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer
SpatialReference: 102719
Visible: True
Transparency: 30
Dynamic: True
Allow_Raster_Function: True
ProcessingTemplateNames: None RFTAspectColor RFTHillshade RFTShadedReliefElevationColorRamp
*/

另请参阅

MapLayer.Names - 此 .NET 方法用于返回当前工程图中包含的地图和影像图层名称的索引字典。

esri_maplayer_get - 此 AutoLISP 函数用于返回指定图层索引编号的地图或影像图层属性。