2012-08-01 90 views
0

我有一個谷歌地圖活動與步道,pois,接近警報等,我想把一個新的PNG地圖(新圖層)在當前谷歌地圖在相同的位置(校準緯度和經度)。我怎麼能這樣做?校準PNG谷歌地圖

此致敬禮

回答

1

使用谷歌地圖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); 
    } 

} 
0

您是否嘗試將兩個視圖添加到FrameLayout?然而,我會建議你讓頂層的透明。

Using Surface View for camera and others for overlay image

+0

和谷歌地圖功能(縮放,標記等)呢?一切都會正常工作? – 2012-08-01 13:00:34

+0

也許你應該向我們展示你已經嘗試過的代碼,我們可以從那裏幫助 – 2012-08-01 13:27:12