public void mapView() { mMapView = (MapView)findViewById(R.id.bmapsView); mMapView.setBuiltInZoomControls(true); //设置启用内置的缩放控件 MapController mMapController = mMapView.getController(); // 得到mMapView的控制权,可以用它控制和驱动平移和缩放 GeoPoint point = new GeoPoint((int)(39.915* 1E6),(int)(116.404* 1E6)); //用给定的经纬度构造一个GeoPoint,单位是微度 (度 * 1E6) mMapController.setCenter(point);//设置地图中心点 mMapController.setZoom(18);//设置地图zoom级别 }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Must be initialized before setContentView mBMapMan = new BMapManager(getApplication()); mBMapMan.init(BAIDU_MAPS_KEY, this); setContentView(R.layout.venue_activity); initSearchText(); initActionBar(); mMapView = (MapView) findViewById(R.id.mapView); mMapView.setBuiltInZoomControls(ZOOM_CONTROLS_ENABLED); MapController mMapController = mMapView.getController(); mMapController.setCenter(DEFAULT_LOCATION_BEIJING); mMapController.setZoom(DEFAULT_ZOOM_LEVEL); if (getIntent().getExtras() != null) { final String shareId = getIntent().getExtras().getString("shareId"); mShare = ReadShare.requestShare(shareId, this); } else { mShare = WriteShare.initNewShare(); } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); mFragment = VenueListFragment.newInstance(); ft.replace(R.id.venueFragmentContainer, mFragment); ft.commit(); setupLocationClient(); setupLocationManager(); // Tiananmen Square coords mSearchHelper = new VenueSearchHelper(mFragment, 39.915, 116.404); }