首页 / 浏览问题 / 移动GIS / 问题详情
在进行地图的POI搜索时,具体搜索某一地点,底图(天地图)会消失.
30EXP 2023年07月10日

部分代码: 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(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); } } } } class MapGestureListener extends GestureDetector.SimpleOnGestureListener{ int i; public MapGestureListener(int i){ this.i=i; } @Override public void onLongPress(MotionEvent e) { Recordset recordset=null; Layer layer=mapControl.getMap().getLayers().get(i); layer.setSelectable(true); recordset=layer.getSelection().toRecordset(); if(recordset!=null){ if(recordset.getRecordCount()<1){ return; } name=recordset.getFieldValue("name").toString(); address=recordset.getFieldValue("address").toString(); type=recordset.getFieldValue("type").toString(); Geometry geometry=recordset.getGeometry(); Point2D locationFile=geometry.getInnerPoint(); LayoutInflater layoutInflater=getLayoutInflater(); View view=layoutInflater.inflate(R.layout.resultcall,null); TextView nameText=view.findViewById(R.id.name); nameText.setText(name); TextView typeText=view.findViewById(R.id.type); typeText.setText(type); TextView addressText=view.findViewById(R.id.address); addressText.setText(address); CallOut call=new CallOut(CONTEXT); call.setContentView(view); call.setCustomize(true); call.setLocation(locationFile.getX(),locationFile.getY()); mapView.removeAllCallOut(); mapView.addCallout(call); mapView.showCallOut(); recordset.dispose(); mapControl.setGestureDetector(new GestureDetector(longTouchListener)); } super.onLongPress(e); } }

1个回答

您好,请确认天地图是否超过了最小层级,超过的话则会显示空白瓦片
3,685EXP 2023年07月10日
我是将工作空间存储到手机中,我改了查询后不同大小的比例后,查询后还是不能显示天地图
不是层级问题,大概率是范围问题,请确认定位位置没有超过地图范围
...