Android 选择集问题,我将选择集设置的风格,在地图上无法显示出来,风格也没有改变,但是我打印出来选择集的风格是改变了,在地图上没有变化,具体代码如下:
m_mapControl.getMap().getLayers().get(layer_title).getSelection().clear();
DatasetVector datasetVector = (DatasetVector) m_mapControl.getMap().getLayers().get(layer_title).getDataset();
QueryParameter queryParameter = new QueryParameter();
queryParameter.setAttributeFilter("SmID=" + smid);
queryParameter.setCursorType(CursorType.STATIC);
Recordset query_recordset = datasetVector.query(queryParameter);
query_recordset.moveFirst();
m_mapControl.getMap().getLayers().get(layer_title).getSelection().fromRecordset(query_recordset);
// 设置选择集的风格
GeoStyle style = new GeoStyle();
style.setLineColor((new 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 Color(244, 50, 50));
style.setFillOpaqueRate(70);
m_mapControl.getMap().getLayers().get(layer_title).getSelection().setStyle(style);
PrjCoordSys prjCoordSys = m_mapControl.getMap().getLayers().get(layer_title).getDataset().getPrjCoordSys();
PrjCoordSys map_prjCoordSys = m_mapControl.getMap().getPrjCoordSys();
if (prjCoordSys.isSame(map_prjCoordSys)) {
Rectangle2D bounds = query_recordset.getGeometry().getBounds();
m_mapControl.getMap().setViewBounds(bounds);
m_mapControl.getMap().refresh();
} else {
Rectangle2D bounds = query_recordset.getGeometry().getBounds();
Point2D leftbottom = new Point2D(bounds.getLeft(), bounds.getBottom());
Point2D righttop = new Point2D(bounds.getRight(), bounds.getTop());
Point2Ds bound_2Ds = new Point2Ds();
bound_2Ds.add(leftbottom);
bound_2Ds.add(righttop);
if (bound_2Ds != null) {
boolean inverse = CoordSysTranslator.inverse(bound_2Ds, prjCoordSys);
if (inverse) {
Rectangle2D new_bounds = new Rectangle2D(bound_2Ds.getItem(0).getX(), bound_2Ds.getItem(0).getY(),
bound_2Ds.getItem(1).getX(), bound_2Ds.getItem(1).getY());
m_mapControl.getMap().setViewBounds(new_bounds);
m_mapControl.getMap().refresh();
} else {
Toast.makeText(main_activity, "无法定位到该图层", Toast.LENGTH_SHORT).show();
}
}
}