ms.FILL_PARENT));
MyIcon2 m2 = new MyIcon2(this);
getWindow().addContentView(
m2,
new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
mMapView = (MapView) findViewById(R.id.bmapsView);
mMapController = mMapView.getController();
initMapView();
app = MyApplication.getInstance();
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
//搜索初始化
mkSerach = new MKSearch();
mkSerach.init(app.mBMapManager, new MKSearchListener() {
@Override
public void onGetWalkingRouteResult(MKWalkingRouteResult arg0,
int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetTransitRouteResult(MKTransitRouteResult arg0,
int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onGetPoiDetailSearchResult(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetDrivingRouteResult(MKDrivingRouteResult arg0,
int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void onGetAddrResult(MKAddrInfo info, int arg1) {
showAddr.setText(info.strAddr);
}
});
//设置地图相关
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
option.setCoorType("bd09ll");
option.setScanSpan(300000);
mLocClient.setLocOption(option);
mLocClient.start();
mMapView.getController().setZoom(16);
mMapView.getController().enableClick(true);
mMapView.displayZoomControls(true);
mMapListener = new MKMapViewListener() {
public void onMapMoveFinish() {
}
public void onClickMapPoi(MapPoi mapPoiInfo) {
// TODO Auto-generated method stub
String title = "";
if (mapPoiInfo != null) {
title = mapPoiInfo.strText;
Toast.makeText(MainActivity.this, title, Toast.LENGTH_SHORT)
.show();
}
}
};
mMapView.regMapViewListener(MyApplication.getInstance().mBMapManager,
mMapListener);
myLocationOverlay = new MyLocationOverlay(mMapView);
locData = new LocationData();
myLocationOverlay.setData(locData);
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
mMapView.refresh();
}
private void initMapView() {
mMapView.setLongClickable(true);
}
/**
* 监听函数,又新位置的时候,格式化成字符串,输出到屏幕中
*/
public class MyLocationListenner implements BDLocationListener {
public void onReceiveLocation(BDLocation location) {
if (location == null)
return;
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
locData.direction = 2.0f;
locData.accuracy = location.getRadius();
locData.direction = location.getDerect();
Log.d("loctest",
String.format("before: lat: %f lon: %f",
location.getLatitude(), location.getLongitude()));
myLocationOverlay.setData(locData);
mMapView.refresh();
mMapController
.animat |