本帖最后由 zhangjie201412 于 2012-11-22 11:10:41 编辑

解决方案 »

  1.   

    sercher.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
    // TODO Auto-generated method stub

    //mSearch.suggestionSearch(address.getText().toString());
    mSearch.poiSearchInCity(address.getText().toString(),address.getText().toString());
    if(!mydrawer.isOpened())
    {
    mydrawer.open();
    goal.setText(address.getText().toString());
    cityname=address.getText().toString();
    }
    }
    });

    mBMapMan = new BMapManager(getApplication());
            mBMapMan.init("D34BB8CA4F7C3947ACBCC6A186D4BC03F5916492", null);
            super.initMapActivity(mBMapMan);
            
            mMapView = (MapView)findViewById(R.id.mapView);
            mylayout=(RelativeLayout)findViewById(R.id.set);
            
            mylayout.setOnTouchListener(this);
          //  mMapView.setOnTouchListener(this);
            address.setOnTouchListener(this);
            mMapView.setBuiltInZoomControls(true);
            //设置在缩放动画过程中也显示overlay,默认为不绘制
            mMapView.setDrawOverlayWhenZooming(true);
            
            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.init(mBMapMan, new MKSearchListener(){ public void onGetPoiResult(MKPoiResult res, int type, int error) {
    // 错误号可参考MKEvent中的定义
    if (error != 0 || res == null) {
    Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
    return;
    }     // 将地图移动到第一个POI中心点
        if (res.getCurrentNumPois() > 0) {
        // 将poi结果显示到地图上
    PoiOverlay poiOverlay = new PoiOverlay(SetAddress.this, mMapView);
    poiOverlay.setData(res.getAllPoi());
        mMapView.getOverlays().clear();
        mMapView.getOverlays().add(poiOverlay);
        mMapView.invalidate();
         mMapView.getController().animateTo(res.getPoi(0).pt);
        } else if (res.getCityListNum() > 0) {
        
        
         mSearch.poiSearchInCity(res.getCityListInfo(0).city,address.getText().toString());
         String strInfo = "在";
         for (int i = 0; i < res.getCityListNum(); i++) {
         strInfo += res.getCityListInfo(i).city;
         strInfo += ",";
         }
         strInfo += "找到结果";
    Toast.makeText(SetAddress.this, strInfo, Toast.LENGTH_LONG).show();
        }
    }
    public void onGetDrivingRouteResult(MKDrivingRouteResult res,
    int error) {
    }
    public void onGetTransitRouteResult(MKTransitRouteResult res,
    int error) {
    }
    public void onGetWalkingRouteResult(MKWalkingRouteResult res,
    int error) {
    }
    public void onGetAddrResult(MKAddrInfo res, int error) {
    }
    public void onGetBusDetailResult(MKBusLineResult result, int iError) {
    }
    public void onGetSuggestionResult(MKSuggestionResult res, int arg1) {
    // TODO Auto-generated method stub
    if (arg1 != 0 || res == null) {
    Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
    return;
    }
    int nSize = res.getSuggestionNum();
    mStrSuggestions = new String[nSize];
    for (int i = 0; i < nSize; i++) {
    mStrSuggestions[i] = res.getSuggestion(i).city + res.getSuggestion(i).key;
    }
    // ArrayAdapter<String> suggestionString = new ArrayAdapter<String>(.this, android.R.layout.simple_list_item_1,mStrSuggestions);
    // mSuggestionList.setAdapter(suggestionString);
    Toast.makeText(SetAddress.this, "suggestion callback", Toast.LENGTH_LONG).show(); }
                public void onGetRGCShareUrlResult(String arg0, int arg1) {
                    // TODO Auto-generated method stub
                    
                }

            });
        
           
        }