是代码的问题吗?可以帮忙看看吗
private void getquery(){
mapView.removeAllCallOut();
String in=editText.getText().toString().trim();
if(in.length()==0){
Toast.makeText(CONTEXT,"请输入名字",Toast.LENGTH_SHORT).show();
}else {
Datasource locationDatasource=workspace.getDatasources().get("DATA");
String query="name like '%" + in + "%'";
DatasetVector locationdata=(DatasetVector) locationDatasource.getDatasets().get("park_1");
Recordset recordset = locationdata.query ( query, CursorType.STATIC );
if(recordset.getRecordCount()>0){
showRecord(recordset);
//mapControl.setGestureDetector(new GestureDetector(new MapGestureListener(0)));
}else {
DatasetVector locationdata2=(DatasetVector) locationDatasource.getDatasets().get("hospital_1");
Recordset recordset2 = locationdata2.query ( query, CursorType.STATIC );
if(recordset2.getRecordCount()>0){
showRecord(recordset2);
//mapControl.setGestureDetector(new GestureDetector(new MapGestureListener(1)));
}else {
DatasetVector locationdata3=(DatasetVector) locationDatasource.getDatasets().get("WC");
Recordset recordset3 = locationdata3.query ( query, CursorType.STATIC );
showRecord(recordset3);
//mapControl.setGestureDetector(new GestureDetector(new MapGestureListener(2)));
}
}
}
}
private void showRecord(Recordset recordset){
if(recordset.getRecordCount()>0){
Map getmap=mapView.getMapControl().getMap();
recordset.moveFirst();
while (!recordset.isEOF()){
GeoPoint geoPoint=(GeoPoint) recordset.getGeometry();;
callout(geoPoint);
recordset.moveNext();
}
if (recordset.getRecordCount()==1){
recordset.moveFirst();
GeoPoint geoPoint = (GeoPoint) recordset.getGeometry();
Point2D point2d = new Point2D(geoPoint.getX(), geoPoint.getY());
getmap.setCenter(point2d);
getmap.setScale(1.0 / 50000);
getmap.refresh();
}else {
Rectangle2D rc = recordset.getBounds();
getmap.setViewBounds(rc);
getmap.zoom(0.5);
getmap.refresh();
}
}else {
Toast.makeText(CONTEXT, "没有符合条件的记录,请重新输入", Toast.LENGTH_SHORT).show();
}
// recordset.dispose();
}
private void callout(GeoPoint geoPoint){
CallOut callOut=new CallOut(CONTEXT);
ImageView imageView=new ImageView(CONTEXT);
imageView.setBackgroundResource(R.drawable.ic_btn_poi);
callOut.setContentView(imageView);
callOut.setCustomize(true);
callOut.setLocation(geoPoint.getX(),geoPoint.getY());
mapView.addCallout(callOut);
}
private void showList(Recordset recordset) {
if (recordset.getRecordCount() > 0) {
getResult = new ArrayList<>();
Map getmap = mapView.getMapControl().getMap();
recordset.moveFirst();
while (!recordset.isEOF()) {
String getGet = recordset.getFieldValue("name").toString();
getResult.add(getGet);
recordset.moveNext();
}
getR = new String[recordset.getRecordCount()];
for (int i = 0; i < recordset.getRecordCount(); i++) {
getR[i] = getResult.get(i);
}
listPopupWindow.setAdapter(new ArrayAdapter<String>(CONTEXT, android.R.layout.simple_list_item_1, getR));
listPopupWindow.setAnchorView(editText);
listPopupWindow.setModal(false);
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
editText.setText(getR[position]);
listPopupWindow.dismiss();
}
});
listPopupWindow.show();
}
}
private void showResultList(){
String in=editText.getText().toString().trim();
if(in.isEmpty()){
}else {
Datasource locationDatasource=workspace.getDatasources().get("DATA");
String query="name like '%" + in + "%'";
DatasetVector locationdata=(DatasetVector) locationDatasource.getDatasets().get("park_1");
Recordset recordset = locationdata.query ( query, CursorType.STATIC );
if(recordset.getRecordCount()>0){
showList(recordset);
}else {
DatasetVector locationdata2=(DatasetVector) locationDatasource.getDatasets().get("hospital_1");
Recordset recordset2 = locationdata2.query ( query, CursorType.STATIC );
if(recordset2.getRecordCount()>0){
showList(recordset2);
}else {
DatasetVector locationdata3=(DatasetVector) locationDatasource.getDatasets().get("WC");
Recordset recordset3 = locationdata3.query ( query, CursorType.STATIC );
showList(recordset3);
}
}
}
}