Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see com.amap.mapapi.map.ItemizedOverlay#draw(android.graphics.Canvas,
   * com.amap.mapapi.map.MapView, boolean)
   */
  @Override
  public void draw(Canvas arg0, MapView arg1, boolean arg2) {
    // TODO Auto-generated method stub
    super.draw(arg0, arg1, arg2);

    boundCenterBottom(mDrawable);
  }
 @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 paintText = new Paint();
     paintText.setColor(Color.BLACK);
     paintText.setTextSize(15);
     canvas.drawText(title, point.x - 30, point.y - 25, paintText); // 绘制文本
   }
   super.draw(canvas, mapView, shadow);
   // 调整一个drawable 边界,使得(0,0)是这个drawable 底部最后一行中心的一个像素
   boundCenterBottom(marker);
 }