在我的项目中,我使用ArcGIS Runtime for Android中的import paramiko
import sys
import time
HOST = "10.11.214.143"
USER = "admin"
PASS = "passwd"
client1=paramiko.SSHClient()
client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client1.connect(HOST,username=USER,password=PASS)
print "SSH connection to %s established" %HOST
#copying config to tftp
stdin, stdout, stderr = client1.exec_command('copy nvram:startup-config tftp: 10.11.214.144')
print stdout.read()
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
client1.exec_command('copy nvram:startup-config tftp:')
File "C:\Python27\lib\site-packages\paramiko\client.py", line 436, in exec_command
chan = self._transport.open_session(timeout=timeout)
File "C:\Python27\lib\site-packages\paramiko\transport.py", line 716, in open_session
timeout=timeout)
File "C:\Python27\lib\site-packages\paramiko\transport.py", line 800, in open_channel
raise SSHException('SSH session not active')
SSHException: SSH session not active
。我对多边形内的要素执行查询并使用某个属性值。搜索完成后,我想清除地图上的所有现有图形。我试过了MapView
,但它清除了我的所有图层!如何清除所有图形而不是删除所有图层?
这是我的代码:
map.removeAll()
答案 0 :(得分:1)
MapView.removeAll()
从地图中删除所有图层。那不是你想要的。
相反,尝试循环遍历MapView
的图层以及GraphicsLayer
类型的每个图层(但不是类型ArcGISFeatureLayer
),要么删除图层,要么删除图形层。做这样的事情:
private void somewhereInYourExistingCode() {
...
for (Layer layer : map.getLayers()) {
clearGraphics(layer);
}
...
}
private void clearGraphics(Layer layer) {
/**
* ArcGISFeatureLayer extends GraphicsLayer, but what you're
* probably looking for is GraphicsLayer objects that are
* not of type ArcGISFeatureLayer.
*/
if (layer instanceof GraphicsLayer && !(layer instanceof ArcGISFeatureLayer)) {
// You can call map.removeLayer(layer), or...
((GraphicsLayer) layer).removeAll();
} else if (layer instanceof GroupLayer) {
GroupLayer groupLayer = (GroupLayer) layer;
for (Layer sublayer : groupLayer.getLayers()) {
// Recursive call
clearGraphics(sublayer);
}
}
}