在谷歌地图上校准PNG

时间:2012-08-01 12:13:39

标签: android google-maps png tiles layer

我有一个谷歌地图活动,包括路径,pois,接近警报等。我想在当前谷歌地图上放置一个新的PNG地图(新图层)在同一位置(由纬度和经度校准)。我怎么能这样做?

祝你好运

2 个答案:

答案 0 :(得分:1)

使用Google地图Overlay功能。以下是需要完成的工作的大致轮廓。

public class PNGOverlay extends Overlay {
  Bitmap mImage;
  // Allocate once and reuse
  private final Paint mPaint = new Paint();

  PNGOverlay(Bitmap image) {
    mImage=image;

    // Configure paint so image is transparent 
  }

  /**
  * Draw the overlay over the map.
  * 
  * @see com.google.android.maps.Overlay#draw(Canvas, MapView, boolean)
  */
  @Override
  public void draw(Canvas canvas, MapView mapv, boolean shadow) {
    // Use projection to figure out where to draw
    Point center = new Point();
    Projection projection = mapv.getProjection();
    projection.toPixels(new GeoPoint(lat,lon), p);

    // Transform image to fill the correct area
    Matrix matrix = new Matrix;
    // Do stuff

    // Draw the image
    canvas.drawBitmap(mImage, matrix, mPaint);
  }

}

答案 1 :(得分:0)

您是否尝试将两个视图添加到FrameLayout?不过,我建议您将顶部透明化。

Using Surface View for camera and others for overlay image