1.使用googleMap 项目必须使用google APIS
2.必须申请key

 protected void onCreate(Bundle arg0) {super.onCreate(arg0); setContentView(R.layout.map);mapView = (MapView)findViewById(R.id.map);// 设置显示模式     //  mapView.setTraffic(true);     mapView.setSatellite(true);//是否卫星模式     mapView.setStreetView(false);      //设置缩放模式     mapView.setBuiltInZoomControls(true);     GeoPoint geoPoint = new GeoPoint((int)(22.548723*1E6),(int)(113.936591*1E6));     mapCon=mapView.getController();     mapCon.setCenter(geoPoint);     mapCon.setZoom(15);     Projection projection = mapView.getProjection();       //进行画布     List<Overlay> overlays = mapView.getOverlays();     overlays.add(new MyPostionOverlay(projection,geoPoint ));   }

/** * 主要是画图 将标记位置 * @author Administrator * */public class MyPostionOverlay extends Overlay {private Projection projection;private GeoPoint geoPoint; public MyPostionOverlay(Projection projection, GeoPoint geoPoint ){this.projection=projection;this.geoPoint=geoPoint;}@Overridepublic void draw(Canvas canvas, MapView mapView, boolean shadow) {super.draw(canvas, mapView, shadow);//准备园图Point point = new Point();Paint paint = new Paint();paint.setColor(Color.RED);paint.setAntiAlias(true);paint.setStyle(Style.FILL);//经度转像素projection.toPixels(geoPoint, point);//将图画到上层canvas.drawCircle(point.x, point.y, 6.0f, paint); }


布局文件中加入
<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0L96i8AoAKKTN50BsQTVZJDpNM48n34utP2nhTg"/>

android:apiKey是申请的key

不要忘记申请权限和导入mapslib
在application标签中加入
<uses-library android:name="com.google.android.maps"/>

更多相关文章

  1. Android(安卓)ApiDemos示例解析(183):Views->Progress Bar->2. S
  2. Android(安卓)Path里FillType功能
  3. android gpuimage显示的缩放和剪裁模式
  4. android中一种欢迎界面模式
  5. android AudioManager类 详解
  6. Activity四种启动模式:standard、singleTop、singleTask、singleI
  7. Activity启动模式设置(堆栈中的生存时间)
  8. android canvas实现在图片上画图
  9. 阅读《Android(安卓)从入门到精通》(9)——多项选择

随机推荐

  1. 【记账小程序】记账系统备注与收入功能完
  2. JS判断当前屏幕是否支持触摸
  3. JS 对象基本用法
  4. PHP:【商城后台管理系统】admin超级管理
  5. python抓取微信撤回消息
  6. PHP:【商城后台管理系统】admin超级管理
  7. thinkphp多数据库访问 - 创建博客页面路
  8. 数组的一些基本函数
  9. JAVA的环境搭建
  10. VS Code常用插件