使用google map 需要注册 Android 地图 API 密钥
方法如下:
1. 首先先要获取你的debug keystore位置:

打开Eclipse--->Windows--->Preferences--->Android--->Build
查看默认的debug keystore位置,我的是C:\Documents and Settings\MYNAME \.android\debug.keystore

2. 在cmd中运行:

keytool -list -keystore 第一步找到的路径/.android/debug.keystore 注意加上引号
回车后出现输入密码:直接回车就可以了

执行结果:
androiddebugkey, May 4, 2009, PrivateKeyEntry,

Certificate fingerprint (MD5): XX:XX:XX:XX:XX:XX:XX:XX.............
这里的XX:XX:XX:XX:XX:XX:XX:XX.............就是你的认证指纹

3. 打开http://code.google.com/intl/zh-CN/android/maps-api-signup.html



4. 使用得到的apiKey:

在layout中加入MapView
<com.google.android.maps.MapView      android:id="@+id/mapview"      android:layout_width="fill_parent"      android:layout_height="fill_parent"        android:apiKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXX" />

5.在manifest.xml 加上权限
    <uses-library android:name="com.google.android.maps"></uses-library>                <uses-permission android:name="android.permission.INTERNET" />   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

6.建立工程
注意这里要选择的buildtarget为"GoogleAPIs" 建立google api adv
如果用到了google api 那么就需要在建立google 的 adv,跟新建普通的adv一样,
eclipse --windows---virtual devices--new---出来对话框在target选择google apis 即OK

7.activity code
 public class TestMap extends MapActivity {    /** Called when the activity is first created. */private MapView mapView = null;private MapController mapCon = null;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        mapView = (MapView)findViewById(R.id.map);     // 设置显示模式      //  mapView.setTraffic(true);        mapView.setSatellite(false);        mapView.setStreetView(false);        //设置缩放模式       mapView.setBuiltInZoomControls(true);                // 设置初始地图的中心位置 113°46' 22°27'   39.95 116.37        GeoPoint geoBeijing=new GeoPoint((int)(22.27*1000000), (int)(113.46*1000000));        mapCon=mapView.getController();        mapCon.setCenter(geoBeijing);        mapCon.setZoom(15);    }

更多相关文章

  1. Android开发:观察者模式应用实例
  2. Android(OPhone) 学习笔记 - 地图(2)
  3. Android 的 Recovery 模式分析
  4. Android夜间模式实现(系统自带)
  5. android 开发谷歌地图的步骤

随机推荐

  1. android中JSON数据的读写方法
  2. Retrofit2.0+RxJava+MVP+Bmob的使用
  3. android activity
  4. Android中RelativeLayout各个属性的含义
  5. Android下的图形渲染配置文件egl.cfg
  6. 后台(02)——MySQL(2)
  7. AndroidStudio ListView 简单使用 (使用a
  8. Android Studio安卓学习笔记(二)Android
  9. Android外设AOA技术原理
  10. Android(安卓)之窗口小部件高级篇--App W