4.30(小组冲刺第五天)

完成定位接受
/**
* 接收异步返回的定位结果
*
* @param aMapLocation
*/
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
//地址
String address = aMapLocation.getAddress();
String latitude = aMapLocation.getAddress();
String longitude = aMapLocation.getAddress();
// tvContent.setText(address == null ? "无地址" : address);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("纬度:" + latitude + "\n");
stringBuffer.append("经度:" + longitude + "\n");
stringBuffer.append("地址:" + address + "\n");

            //tvContent.setText(stringBuffer.toString());

            Log.d("MainActivity",stringBuffer.toString());
            showMsg(address);
            //停止定位后,本地服务并不会销毁
            mLocationClient.startLocation();
            //显示地图定位结果
            if(mListener !=null){
                //显示系统图标
                mListener.onLocationChanged(aMapLocation);
            }

        } else {
            //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
            Log.e("AmapError", "location Error, ErrCode:"
                    + aMapLocation.getErrorCode() + ", errInfo:"
                    + aMapLocation.getErrorInfo());
        }
    }
}
posted @ 2024-04-30 23:36  孤儿组  阅读(15)  评论(0)    收藏  举报