查了不少网址终于把android maps搞定,总结如下:

0.环境: 0.1 android-sdk-windows-1.0_r2.zip 0.2 eclipse-java-europa-winter-win32.zip v3.3.2 + SDK Plugin 1.API KEY 申请 C:/Documents and Settings/3-301-1/Local Settings/Application Data/Android>keytoo l -list -alias androiddebugkey -keystore debug.keystore -storepass android -keyp ass android androiddebugkey, 2008-12-6, PrivateKeyEntry, 认证指纹 (MD5): ×××××××××××××××××××××××××××××××××××××× ×××××××××××××××××××××××××××××××××××××× ×××××××××××××××××××××××××××××××××××××× <com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="××××××××××××××××××××××××××××××××××××××" /> 2.编写程序 http://www.qphone.net/ http://www.qphone.net/2008/12/21/android平台上的mapview开发-2-一个读取地图并且可以缩放设置/ 2.1设置上网权限 <uses-permission android:name="android.permission.INTERNET" /> 2.2设置界面xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.android.maps.MapView android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="××××××××××××××××××××××××××××××××××××××" android:clickable="true" /> </RelativeLayout> 2.3源代码
  1. packagecom.chen;
  2. importandroid.os.Bundle;
  3. importandroid.view.View;
  4. importandroid.widget.Button;
  5. importcom.google.android.maps.GeoPoint;
  6. importcom.google.android.maps.MapActivity;
  7. importcom.google.android.maps.MapController;
  8. importcom.google.android.maps.MapView;
  9. publicclassBasicMapAppextendsMapActivity{
  10. MapViewmapView;
  11. MapControllermapController;
  12. booleanisSatellite=false;
  13. @Override
  14. publicvoidonCreate(Bundleicicle){
  15. super.onCreate(icicle);
  16. setContentView(R.layout.main);
  17. mapView=(MapView)findViewById(R.id.map);
  18. mapController=mapView.getController();
  19. mapController.setZoom(15);
  20. updateView();
  21. }
  22. privatevoidupdateView(){
  23. Doublelat=31.23717*1E6;
  24. Doublelng=121.50811*1E6;
  25. GeoPointpoint=newGeoPoint(lat.intValue(),lng.intValue());
  26. mapController.setCenter(point);
  27. //放大地图,缩放等级加
  28. ButtonbtnZoomIn=(Button)findViewById(R.id.zoomin);
  29. btnZoomIn.setOnClickListener(newView.OnClickListener(){
  30. publicvoidonClick(Viewview){
  31. mapController.setZoom(mapView.getZoomLevel()+1);
  32. }
  33. });
  34. //缩小地图,缩放等级减
  35. ButtonbtnZoomOut=(Button)findViewById(R.id.zoomout);
  36. btnZoomOut.setOnClickListener(newView.OnClickListener(){
  37. publicvoidonClick(Viewview){
  38. mapController.setZoom(mapView.getZoomLevel()-1);
  39. }
  40. });
  41. //缩小地图,缩放等级减
  42. ButtonbtnSatellite=(Button)findViewById(R.id.satellite);
  43. btnSatellite.setOnClickListener(newView.OnClickListener(){
  44. publicvoidonClick(Viewview){
  45. if(isSatellite==false){
  46. mapView.setSatellite(true);//卫星模式为True
  47. mapView.setTraffic(false);//交通模式为False
  48. mapView.setStreetView(false);//街景模式为False
  49. isSatellite=true;
  50. }else{
  51. mapView.setSatellite(false);
  52. isSatellite=false;
  53. }
  54. }
  55. });
  56. }
  57. @Override
  58. protectedbooleanisRouteDisplayed(){
  59. returnfalse;
  60. }
  61. }

更多相关文章

  1. Android获取本地图片之ACTION_GET_CONTENT与ACTION_PICK区别
  2. Android不错的图片压缩方法
  3. android之Matrix
  4. Android(安卓)利用Matrix实现图片随手指平移、旋转、缩放
  5. [Android]你不知道的Android进程化(3)--进程等级
  6. android小知识(1)
  7. Android百度地图之位置定位和附近查找代码简单实现 (上)
  8. Android设置拍照或者上传本地图片
  9. Android实现图片缩放与旋转

随机推荐

  1. ANDROID开机动画分析
  2. Git,SVN使用方法杂记(更新中)
  3. 编译Android版本的libmad
  4. Android IPC的6种方式
  5. Android中maxSdkVersion、minSdkVersion
  6. Android 签名(META-INF)
  7. Android Manifest.xml 结构详解
  8. Android(安卓)菜单BoomMenu(悬浮按钮弹出
  9. Android(安卓)Plugins
  10. android技术专题之二-telephony