我刚刚将项目从 arcgis runtime 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链接: - link to show hide the image layer
但是在使用上述程序获得子层数据时,它给出了 me 10个子层数据
但根据我使用方法的链接
dynamicMapServiceLayer.mapImageSublayers.count
然后它只返回两个对象或子图层 因此,我无法实现节目隐藏功能
那么我应该如何在我的案例中使用上述链接方法?或者还有其他方法吗?
答案 0 :(得分:0)
通过搜索api,我找到了隐藏或显示dynamicMap图层的解决方案( 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)
}
}
}
像这样的隐藏图层
for i in 0 ...((dynamicMapServiceLayer?.mapImageSublayers.count)! - 1){ 让layer = dynamicMapServiceLayer?.mapImageSublayers [i]为! AGSArcGISMapImageSublayer
for subLayer in layer.subLayerContents {
if visibleLayers.contains(subLayer.name) {
subLayer.isVisible = false
}
else {
subLayer.isVisible = true
}
}
}