使用产品:imobile 操作系统:win7
数据类型:x64
问题详细描述:关键代码如下:
private void QueryArea(String key){
// TODO Auto-generated method stub
Layer layer = null;
String strLayerName = key;
Log.i("8888877777",strLayerName);
// String strLayerName = m_spnSelectLayer.getSelectedItem().toString();
if (strLayerName.equals("")) {
return;
}else {
layer = m_MapControl.getMap().getLayers().get(strLayerName);
Log.i("8888333","不是空的");
}
DatasetVector datasetvector = (DatasetVector)layer.getDataset();
// 清空选择集
for (int i = 0; i < m_MapControl.getMap().getLayers().getCount(); i++) {
Layer ly = m_MapControl.getMap().getLayers().get(i);
ly.getSelection().clear();
}
Rectangle2D bounds = getBounds();
// System.out.println(bounds.toString());
// System.out.println(layer.getName());
Log.i("88885555",bounds.toString());
Log.i("888885555",layer.getName());
// 查询,返回查询结果记录集
Recordset recordset = datasetvector.query(bounds, CursorType.STATIC);
Log.i("88882222",recordset.getRecordCount()+" 999");
if (recordset.getRecordCount()<1) {
Toast.makeText(MainActivity.this, "未搜索到对象" , Toast.LENGTH_SHORT).show();
m_MapControl.getMap().refresh();
recordset.dispose();
return;
}else{
Toast.makeText(MainActivity.this, "Count"+recordset.getRecordCount(), Toast.LENGTH_LONG).show();
}
layer.getSelection().fromRecordset(recordset);
// 设置选择集的风格
GeoStyle style = new GeoStyle();
style.setLineColor((new com.supermap.data.Color(0,0,222)));
style.setLineSymbolID(0);
style.setLineWidth(0.5);
style.setMarkerSymbolID(351);
style.setMarkerSize(new com.supermap.data.Size2D(5,5));
style.setFillForeColor(new com.supermap.data.Color(244,50,50));
style.setFillOpaqueRate(70);
layer.getSelection().setStyle(style);
recordset.moveFirst();
Geometry geometry = recordset.getGeometry();
m_MapControl.getMap().setCenter(geometry.getInnerPoint());
m_MapControl.getMap().refresh();
// 释放资源
recordset.dispose();
geometry.dispose();
}
提示信息:
2020-12-20 00:52:01.062 3642-3642/com.example.supermaptwo I/88888000: 学校_1@yyy
2020-12-20 00:52:01.524 3642-3642/com.example.supermaptwo I/8888877777: 学校_1@yyy
2020-12-20 00:52:01.524 3642-3642/com.example.supermaptwo I/8888333: 不是空的
2020-12-20 00:52:01.527 3642-3642/com.example.supermaptwo I/88885555: Left=103.798979746169,Bottom=30.658870428114835,Right=103.80749666867466,Top=30.667387350620498
2020-12-20 00:52:01.527 3642-3642/com.example.supermaptwo I/888885555: 学校_1@yyy
2020-12-20 00:52:01.529 3642-3642/com.example.supermaptwo I/88882222: 0 999
(学校_1@yyy是工作空间内一个图层的名字)
问题重现步骤: 123