@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;
    }
  }
Exemplo n.º 2
0
 private void checkInitSearch() {
   if (mMKSearch == null) {
     // 初始化搜索模块,注册事件监听
     mMKSearch = new MKSearch();
     mMKSearch.init(mApplication.getMapManager(), this);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mapView = (MapView) findViewById(R.id.bmapview);
    mbtnAdress = (Button) findViewById(R.id.btnAddress);
    mbtnAdress.setOnClickListener(this);
    mbtnLine = (Button) findViewById(R.id.btnLine);
    mbtnLine.setOnClickListener(this);
    bMapManager = new BMapManager(this);
    bMapManager.init(
        key,
        new MKGeneralListener() {

          @Override
          public void onGetPermissionState(int arg0) {
            // TODO Auto-generated method stub
            if (arg0 == 300) {
              Toast.makeText(MainActivity.this, "输入的key有误", 1);
            }
          }

          @Override
          public void onGetNetworkState(int arg0) {}
        });
    bMapManager.start();
    initMapActivity(bMapManager);
    mapView.setBuiltInZoomControls(true); // 设置中心点
    mkSearch = new MKSearch();
    mkSearch.init(bMapManager, new MySearchListener(this, mapView));
  }
Exemplo n.º 4
0
 public void reverseGeocode(GeoPoint location, int reqCode) {
   mReqCodeQueue.offer(reqCode);
   mMKSearch.reverseGeocode(location);
 }