该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
估计是你的代码的问题,简单的代码如下:
package com.wang;
import com.baidu.mapapi.BMapManager;import com.baidu.mapapi.GeoPoint;import com.baidu.mapapi.MapActivity;import com.baidu.mapapi.MapController;import com.baidu.mapapi.MapView;
import android.os.Bundle;
public class Baidu01Activity extends MapActivity { BMapManager mBMapMan; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mBMapMan = new BMapManager(getApplication()); mBMapMan.init("-------------自己申请的APIkey-------------", null); super.initMapActivity(mBMapMan); MapView mMapView = (MapView) findViewById(R.id.bmapsView); mMapView.setBuiltInZoomControls(true); //设置启用内置的缩放控件 MapController mMapController = mMapView.getController(); // 得到mMapView的控制权,可以用它控制和驱动平移和缩放 GeoPoint point = new GeoPoint((int) (32.973657928606265 * 1E6), (int) (112.54251837730408 * 1E6)); //用给定的经纬度构造一个GeoPoint,单位是微度 (度 * 1E6) mMapController.setCenter(point); //设置地图中心点 mMapController.setZoom(12); //设置地图zoom级别 }
@Overrideprotected void onDestroy() { if (mBMapMan != null) { mBMapMan.destroy(); mBMapMan = null; } super.onDestroy();}
@Overrideprotected void onPause() { if (mBMapMan != null) { mBMapMan.stop(); }super.onPause();}
@Overrideprotected void onResume() { if (mBMapMan != null) { mBMapMan.start(); }super.onResume();}
@Overrideprotected boolean isRouteDisplayed() {// TODO Auto-generated method stubreturn false;}}