@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.baidu_map_view); Toolbar toolbar = (Toolbar) findViewById(R.id.map_bar); setSupportActionBar(toolbar); if(getSupportActionBar()!=null) getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true); if (toolbar != null) { toolbar.setTitle(MAP_TITLE); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); } textureMapView = (TextureMapView) findViewById(R.id.bmapView); showShare(); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, container, false); // Inflate the layout for this fragment switchLocation = (Switch) view.findViewById(R.id.switchLocation); switchLBSTrace = (Switch) view.findViewById(R.id.switchLBSTrace); switchLocation.setOnCheckedChangeListener(this); switchLBSTrace.setOnCheckedChangeListener(this); mMapView = (TextureMapView) view.findViewById(R.id.bmapView); baiduMap = mMapView.getMap(); baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null)); application.setMaxZoomLevel(baiduMap.getMaxZoomLevel()); // 开启定位图层 baiduMap.setMyLocationEnabled(true); baiduMap.setOnMarkerClickListener(this); //再次进入地图fragment时界面刷新 if (application.latLng != null) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2); baiduMap.animateMapStatus(u);//动画移动摄像头 if (radarNearbyInfoList != null) { refreshMapUI(); } } return view; }