0

我刚刚将我的项目从arcgis 运行时 10.2 升级到 100.2.1,我能够运行 AGSFeature 图层,但AGSArcGISMapImageLayer出现问题

我只是加载包含子图层的AGSArcGISMapImageLayer图层并像这样获取它们的数据

let mapServiceInfo = (dynamicMapServiceLayer as? AGSArcGISMapImageLayer).mapServiceInfo
  if let layerInfos = mapServiceInfo?.layerInfos {
     for layerInfo in layerInfos {
       //get the sublayer data
     }
}

现在我只是根据用户要求显示和隐藏图层

为此,我检查了此 arcgis 链接:-显示隐藏图像层的链接

但是,在使用上述程序获取子层数据的同时,它给了我 10 个子层数据

但是根据我使用该方法时的链接

dynamicMapServiceLayer.mapImageSublayers.count

然后它只返回两个对象或子层 因此我无法实现显示隐藏功能

那么在我的情况下我应该如何使用上述链接方法?还是有其他方法可以做到这一点?

4

1 回答 1

0

通过搜索 api,我找到了隐藏或显示动态地图图层的解决方案(AGSArcGISMapImageLayer

**layersHidden** is an array which contain the url of layers which I want to hide from map

let mapServiceInfo = dynamicMapServiceLayer?.mapServiceInfo
let layerInfos = mapServiceInfo?.layerInfos

for layerInfo in layerInfos {
     if layerInfo.sublayerIDs.count == 0 {
         // Get the url for the layer.
         let layerUrl = "\(mapServiceInfo?.url?.absoluteString ?? "")/\(UInt(layerInfo.id))"
         // add the name of layers which we want to hide from map in visibleLayers array
         if layersHidden.contains(layerUrl) {
              visibleLayers.append(layerInfo.name)
         }
     }
}

像这样的隐藏层

对于我在 0...((dynamicMapServiceLayer?.mapImageSublayers.count)!-1) { let layer = dynamicMapServiceLayer?.mapImageSublayers[i] as!AGSArcGISMapImageSublayer

for subLayer in layer.subLayerContents {
    if visibleLayers.contains(subLayer.name) {
         subLayer.isVisible = false
    }
    else {
      subLayer.isVisible = true
    }
   }
 } 
于 2018-06-07T05:12:27.160 回答