使用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的屏幕上的title bar
  2. android 模拟器不能上网问题
  3. Android(安卓)的网络编程
  4. 转:Android实现矩形设置菜单
  5. Android(安卓)2.3 StatusBar 分析(二)
  6. EditText的常用点,输入控制(包含inputType)
  7. Android使用ImageView引起Missing contentDescription attribute
  8. Android中使用WebView, WebChromeClient和WebViewClient加载网页
  9. Android(安卓)的网络编程

随机推荐

  1. xml中Android的解析
  2. Android(安卓)反编译资料整理
  3. [android]uiautomator中文输入解决方案
  4. ubuntu下SVN树冲突的解决方法
  5. 如何解决Android中输入法挡住输入框的问
  6. Android之版本检测和更新
  7. android studio导入类库
  8. android动画初级入门
  9. Android(安卓)面向对象编程 类与对象
  10. 关于Android按键处理