private void showMapViewRoutes(List<GPSInfo> lstWgs84HashMap) { ArrayList<GeoPoint> lstWgs84GeoPoint = RoutesHelper.getWgs84GeoPoint(lstWgs84HashMap); // mRoutesOverlay if (mMapView != null) { try { if (mRoutesOverlay != null) { if (mMapView.getOverlays().contains(mRoutesOverlay)) { mMapView.getOverlays().remove(mRoutesOverlay); mRoutesOverlay = null; } } mRoutesOverlay = new RoutesOverlay(mPathActivity, mMapView); { mRoutesOverlay.setOnOverlayEventListener(this); mRoutesOverlay.setData(lstWgs84GeoPoint); } mMapView.getOverlays().add(0, mRoutesOverlay); mMapView.invalidate(); mMapView.getController().animateTo(lstWgs84GeoPoint.get(0)); } catch (Exception e) { e.printStackTrace(); } } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btnAddress: mapView.getOverlays().clear(); // 清除公交站点的标识 mapView.invalidate(); GeoPoint geoPoint = new GeoPoint((int) (39.915 * 1e6), (int) (116.454 * 1e6)); EditText tvAdr = (EditText) findViewById(R.id.etAddress); // 根据中心点geoPoint在1000半径内查询KFC mkSearch.poiSearchNearBy(tvAdr.getText().toString(), geoPoint, 5000); // GeoPoint geoPoint=new GeoPoint(39904965, 116327764); // mkSearch.reverseGeocode(geoPoint); break; case R.id.btnLine: mapView.getOverlays().clear(); // 清除公交站点的标识 EditText etLine = (EditText) findViewById(R.id.etLine); mkSearch.poiSearchInCity("北京", etLine.getText().toString()); // EditText etadd=(EditText) findViewById(R.id.etAddress); // mkSearch.geocode("北京", etadd.getText().toString()); break; default: break; } }