首先继承抽象类 ItemizedOverlay 并重写onTap方法 class MyOverItem extends ItemizedOverlay<OverlayItem> { private List<OverlayItem> GeoList = new ArrayList<OverlayItem>(); private Drawable marker; private Context mContext; //这里写死poi点。。可以从服务器查询获得 private double mLat1 = 40.0506; // point1纬度 private double mLon1 = 116.288700; // point1经度 private double mLat2 = 40.051723; private double mLon2 = 116.287741; private double mLat3 = 40.052723; private double mLon3 = 116.286741; public MyOverItem(Drawable marker, Context context) { super(boundCenterBottom(marker)); this.marker = marker; this.mContext = context; // 用给定的经纬度构造GeoPoint,单位是微度 (度 * 1E6) GeoPoint p1 = new GeoPoint((int) (mLat1 * 1E6), (int) (mLon1 * 1E6)); GeoPoint p2 = new GeoPoint((int) (mLat2 * 1E6), (int) (mLon2 * 1E6)); GeoPoint p3 = new GeoPoint((int) (mLat3 * 1E6), (int) (mLon3 * 1E6)); // 构造OverlayItem的三个参数依次为:item的位置,标题文本,文字片段 GeoList.add(new OverlayItem(p1, "P1", "point1")); GeoList.add(new OverlayItem(p2, "P2", "point2")); GeoList.add(new OverlayItem(p3, "P3", "point3")); //该方法应该是将当前的GeoList的overlay 同步到 父类ItemizedOverlay中的list中以进行重绘 //所以当GeoList数据发生变化时需要调用该方法 populate(); } @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { // Projection接口用于屏幕像素点坐标系统和地球表面经纬度点坐标系统之间的变换 Projection projection = mapView.getProjection(); for (int index = size() - 1; index >= 0; index--) { // 遍历GeoList OverlayItem overLayItem = getItem(index); // 得到给定索引的item String title = overLayItem.getTitle(); // 把经纬度变换到相对于MapView左上角的屏幕像素坐标 Point point = projection.toPixels(overLayItem.getPoint(), null); Paint paintCircle = new Paint(); paintCircle.setColor(Color.RED); canvas.drawCircle(point.x, point.y, 5, paintCircle); // 画圆 Paint paintText = new Paint(); paintText.setColor(Color.BLACK); paintText.setTextSize(15); canvas.drawText(title, point.x, point.y - 25, paintText); // 绘制文本 } super.draw(canvas, mapView, shadow); //调整一个drawable边界,使得(0,0)是这个drawable底部最后一行中心的一个像素 boundCenterBottom(marker); } @Override protected OverlayItem createItem(int i) { return GeoList.get(i); } @Override public int size() { return GeoList.size(); } @Override // 处理当点击事件 //mapview的onTouch事件会传播到overlay的 onTouch方法 通过点击范围可以确定触发哪个overlay的onTap protected boolean onTap(int i) { setFocus(GeoList.get(i)); Toast.makeText(this.mContext, GeoList.get(i).getSnippet(), Toast.LENGTH_SHORT).show(); return true; } } Google API中MapView可以获得Overlay的列表 private void initOverlayItem(){ Drawable marker = getResources().getDrawable(R.drawable.poi_1); //得到需要标在地图上的资源 marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker .getIntrinsicHeight()); //为maker定义位置和边界 mapView.getOverlays().add(new MyOverItem(marker, this)); //添加ItemizedOverlay实例到mMapView } MapView会 根据顺序在onDraw方法中重绘