ARCGIS PRO SDK 常用的选择操作

一、'获取当前图层FeatureLayer选择要素: ly选择要素

     Dim selSet As Selection = ly.GetSelection()    

二、获取当前激活的地图选择要素集: 不同层的所有的选择要素

    Dim selSet As SelectionSet = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection()   

三、用例

      Map:获取地图的选择。 必须在 MCT 上调用此方法。使用 QueuedTask.Run 

1、将地图选择加载到 Inspector 中
     c+

// 获取地图中的当前所选要素
var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
// 获取第一个图层及其对应的所选要素OID
var firstSelectionSet = selectedFeatures.ToDictionary().First();
// 创建检查器类的实例
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// 使用对象ID列表将所选要素加载到检查器中
await inspector.LoadAsync(firstSelectionSet.Key, firstSelectionSet.Value);

    vb :将地图选择加载到 Inspector 中

'获取当前地图选择要素
Dim selSet As SelectionSet = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection()
'获取第一个图层及其对应的所选要素OID
Dim firstSelectionSet = selSet.ToDictionary().First()
'写入字典
Dim selSetDict As Dictionary(Of MapMember, List(Of Long)) = selSet.ToDictionary()
'创建检查器类的实例
Dim insp = new ArcGIS.Desktop.Editing.Attributes.Inspector
'使用对象ID列表将所选要素加载到检查器中
await insp.inspector.LoadAsync(firstSelectionSet.Key, firstSelectionSet.Value)

   vb:将地图图层选择加载到 Inspector 中,统一修改属性MOMC

'获取当前地图选择要素
Dim selSet As SelectionSet = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection()
'Featurelayer ly选择的要素读入列表
Dim selSetDict As List(Of Long) = selSet.ToDictionary(ly)
'创建检查器类的实例
Dim insp = New ArcGIS.Desktop.Editing.Attributes.Inspector()
'使用对象ID列表将所选要素加载到检查器中
Await insp.LoadAsync(ly, selSetDict)
'如果统一修改属性
Dim modifyFeature = New EditOperation()
modifyFeature.Name = "修改属性"
Insp["MOMC"] = 24;
modifyFeatures.Modify(Insp)
if modifyFeatures.IsEmpty Then
   dim result = Await modifyFeatures.ExecuteAsync()
end if 

  vb:将地图图层选择加的要素遍历:对线要素点序反转

Dim selGeom As ArcGIS.Core.Geometry.Polyline
'获取当前地图选择要素
Dim selSet As SelectionSet = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection()
'Featurelayer ly选择的要素读入列表
Dim selSetDict As List(Of Long) = selSet.ToDictionary(ly)
Dim selSetDict As List(Of Long) = selSet.ToDictionary(ly)
For Each lva As Long In selSetDict    '图层循环
    Dim modifyFeature = New EditOperation()
    modifyFeature.Name = "线反转"
    '创建检查器类的实例
    Dim insp = New ArcGIS.Desktop.Editing.Attributes.Inspector()
    '使用对象ID列表将所选要素加载到检查器中
    Await insp.LoadAsync(ly, lva)
    '获取图形进行反向处理
    selGeom = GeometryEngine.Instance.ReverseOrientation(insp.Shape)
    insp.Shape=selGeom
   modifyFeature.Modify(insp)
   If modifyFeature.IsEmpty then
      dim result = modifyFeature.ExecuteAsync()
   End if
Next

   vb:将地图图层选择加的要素遍历:转Feature对线要素点序反转

Dim pFeature As Feature
Dim selGeom As ArcGIS.Core.Geometry.Polyline
Dim rows As RowCursor
Dim selSet As Selection = ly.GetSelection()    '获取当前图层选择要素
If selSet.GetCount = 0 Then
    MsgBox("选择的要素层未选择线要素,不能执行.")
    Exit Sub
End If
rows = selSet.Search(Nothing.false)
Do While rows.MoveNext
    pFeature = rows.Current
    selGeom = GeometryEngine.Instance.ReverseOrientation(pFeature.GetShape)
    pFeature.SetShape(selGeom)
    pFeature.Store()
Loop

3、选择要素闪烁功能
    c+

​​​​​​​public Task FlashSelectedFeaturesAsync()
{
  return QueuedTask.Run(() =>
  {
    //Get the active map view.
    var mapView = MapView.Active;
    if (mapView == null)
      return;

    //从地图中获取所选要素并过滤掉独立表选择.
    //var selectedFeatures = mapView.Map.GetSelection()
    //    .Where(kvp => kvp.Key is BasicFeatureLayer)
    //    .ToDictionary(kvp => (BasicFeatureLayer)kvp.Key, kvp => kvp.Value);

    刷新功能集合.
    //mapView.FlashFeature(selectedFeatures);

    var selectedFeatures = mapView.Map.GetSelection();

    //刷新功能集合.
    mapView.FlashFeature(selectedFeatures);
  });
}

   vb

Dim mapView = MapView.Active
If mapView IS NOTHING =FALSE THEN
       DIM  selectedFeatures = mapView.Map.GetSelection()
      '刷新功能集合.
       mapView.FlashFeature(selectedFeatures)
END IF

你可能感兴趣的:(javascript,开发语言,ecmascript)