@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); type = getIntent().getIntExtra("type", 1); title = getIntent().getStringExtra("title"); setContentView(R.layout.activity_map); mapView = (MapView) findViewById(R.id.mapview); ll_search = (LinearLayout) findViewById(R.id.ll_search); ibtn_back = (ImageButton) findViewById(R.id.ibtn_back); tv_title = (TextView) findViewById(R.id.tv_title); rl_info = (RelativeLayout) findViewById(R.id.rl_info); btn_do = (Button) findViewById(R.id.btn_do); tv_name = (TextView) findViewById(R.id.tv_name); tv_distance = (TextView) findViewById(R.id.tv_distance); tv_addr = (TextView) findViewById(R.id.tv_addr); ibtn_back.setOnClickListener(this); btn_do.setOnClickListener(this); if (!TextUtils.isEmpty(title)) { tv_title.setText(title); } baiduMap = mapView.getMap(); // 显示定位图层 baiduMap.setMyLocationEnabled(true); baiduMap.setOnMapLoadedCallback( new BaiduMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { if (drivingRouteOverlay != null) { drivingRouteOverlay.zoomToSpan(); } if (overlayManager != null) { overlayManager.zoomToSpan(); } } }); baiduMap.setOnMapClickListener( new BaiduMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { if (type == 1) { rl_info.setVisibility(View.GONE); } } @Override public boolean onMapPoiClick(MapPoi mapPoi) { return false; } }); mapView.showScaleControl(true); BDLocUtil.registerLocListener(this); BDLocUtil.requestLocation(); myOrientationListener = new MyOrientationListener(this); myOrientationListener.setOnOritentationListener(this); myOrientationListener.start(); if (type == 1) { // add marker data = (List<MyPoiInfo>) getIntent().getSerializableExtra("data"); addMarker2Map(); } else { // route plan toInfo = (MyPoiInfo) getIntent().getSerializableExtra("to"); requestRoutePlan(toInfo); } }