ARCGIS PRO SDK VB2022 图层操作

一、map添加图层

'pid  添加图层的数据库路径及名称
'ttt  添加数据库中要素类名称
Dim url As String = pid & "\" & ttt   
Dim URI As Uri = New Uri(url)
    Await QueuedTask.Run(Sub()
                             LayerFactory.Instance.CreateLayer(URI, MapView.Active.Map)
                         End Sub)

二、map删除所有图层

Dim pmap as map = MapView.Active.Map;
    '获取所有图层
    Dim lys = map.GetLayersAsFlattenedList()
    '移除所有图层
    Await QueuedTask.Run(Sub()
                          pmap.RemoveLayers(lys)
                        Sub)  

三、map删除指定的图层 ,删除图层名为:TK_LINE

Dim PFeatureLayer As FeatureLayer = Map.FindLayers("TK_LINE").First() 
pMap.RemoveLayer(pLayer)                               '删除层

四、map移动指定的图层 ,图层名为:土地性质图斑

 Dim ttp As Integer = 0
 MapView = MapView.Active
 '获取地图视图的关联地图
 Map = MapView.Map
 For it = 0 To Map.Layers.Count - 1
     If Map.Layers(it).Name = "土地性质图斑" Then
         Layer = CType(Map.Layers(it), FeatureLayer)
         ttp = 1
     End If
 Next
 If ttp = 0 Then
     MsgBox("土地性质图斑层不存在。")
     Exit Sub
 End If
 Await QueuedTask.Run(Sub()
                          '0图层的顺序号,移动至图层最上面
                          '-1图层的顺序号,移动至图层最下面
                          Map.MoveLayer(Layer, 0)    
                      End Sub)

五、获得指定类型的第一个图层数据源layerPath

 Dim path1 As  Uri
 Dim Layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType(Of FeatureLayer)().FirstOrDefault()
 Dim layerPath = Await QueuedTask.Run(Function()
                                          path1 = CType(Layer, FeatureLayer).GetPath().ToString
                                          Return (path1)
                                      End Function)

  六、查找每一个图层的数据源

Dim  lys = pMap.GetLayersAsFlattenedList
lys = pMap.GetLayersAsFlattenedList()
For Each lv In lys
    '获得现图层数据源
    Await QueuedTask.Run(Sub()
                             path1 = lv.GetPath
                         End Sub)
    Exit For
Next

七、替换数据源

Dim lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType(Of FeatureLayer)().FirstOrDefault()().FirstOrDefault();
Await QueuedTask.Run(Sub()
                 DIM  ConnectionStringToReplace = lyr.GetFeatureClass().GetDatastore().GetConnectionString()
                 DIM DatabaseConnectionPath AS String = "新的数据库完整路径"
  lyr.FindAndReplaceWorkspacePath(connectionStringToReplace, databaseConnectionPath, true)
                 End sub)

八、其他

 Dim ttp As Integer = 0
 MapView = MapView.Active
 '获取地图视图的关联地图
 Map = MapView.Map
 For it = 0 To Map.Layers.Count - 1
     If Map.Layers(it).Name = "土地性质图斑" Then
         Layer = CType(Map.Layers(it), FeatureLayer)
         ttp = 1
     End If
 Next
 If ttp = 0 Then
     MsgBox("土地性质图斑层不存在。")
     Exit Sub
 End If 
'=======================设置地图参考比例尺
 pMap.SetReferenceScale(5000)
 '======================= '层的透明度
 Dim ly As Layer = Layer
 ly.SetTransparency(50)
 ly.SetVisibility(False)  '关闭图层
 ly.SetVisibility(True)   '显示图层
 Dim Path = ly.GetPath    '获取图层源的路径

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值