ARCGIS PRO SDK VB2022 修复数据源

将地图数据源设置到工程默认数据库,也可以把地图下的层设置不同的数据源
CIMStandardDataConnection           :通用数据连接
CIMFeatureDatasetDataConnection  :要素数据集数据连接

 Dim dataConnection As CIMStandardDataConnection
 Dim dataConnection1 As CIMStandardDataConnection ' CIMFeatureDatasetDataConnection
 Dim pMapView As MapView
 Dim pMap As Map
 Dim pLayer As FeatureLayer
'打开工程
 dq_tfh =  "工程文件路径 \"工程文件.aprx"
 Await Project.OpenAsync(dq_tfh)
 mapProjItem = Project.Current.GetItems(Of MapProjectItem)().FirstOrDefault()
 Await QueuedTask.Run(Sub()
                          pMap = mapProjItem.GetMap()
                      End Sub)
 '获取默认数据库
 Dim gdbPath As String = Project.Current.DefaultGeodatabasePath
 For IT As Integer = 0 To pMap.Layers.Count - 1
     If UCase(Strings.Right(pMap.Layers(IT).Name, 4)) = ".IMG" Then
         pLayer = CType(pMap.Layers(IT), FeatureLayer)
         pMap.RemoveLayer(pLayer)                                        '删除层
         pMap.MoveLayer(pMap.Layers(0), pMap.Layers.Count - 1)           '移动层
     Else
         If pMap.Layers(IT).Name = "TK_ANNO" Or pMap.Layers(IT).Name = "TL_ANNO" Then   '注记要素类
             annoLayer = CType(pMap.Layers(IT), AnnotationLayer)
             Await QueuedTask.Run(Sub()
                                      dataConnection = CType(annoLayer.GetDataConnection, CIMStandardDataConnection)
                                      dataConnection.WorkspaceConnectionString = "DATABASE=" & gdbPath.ToString 
                                      annoLayer.SetDataConnection(dataConnection)
                                      annoLayer.ClearDisplayCache()
                                  End Sub)
         Else
             pLayer = CType(pMap.Layers(IT), FeatureLayer)
             Await QueuedTask.Run(Sub()
                                      dataConnection1 = CType(pLayer.GetDataConnection, CIMStandardDataConnection)
                                      dataConnection1.WorkspaceConnectionString = "DATABASE=" & gdbPath.ToString
                                      pLayer.SetDataConnection(dataConnection1)

                                  End Sub)
         End If
     End If
     '保存工程
     Await QueuedTask.Run(Sub()
                              Project.Current.SaveAsync()
                          End Sub)
 Next IT

影像数据,只进行了删除,未重新加载

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值