1

我正在尝试使用 mapsforge 映射库将位图覆盖在 android 上的地图上。我正在扩展 Overlay 类,我需要实现 drawOverlayBitmap。有谁知道如何做到这一点?我已经用谷歌搜索了,但是所有结果都使用谷歌的 apis 返回,当你在那里覆盖方法时,你有 mapView 这样更有意义......不知道如何在这里做

public abstract class Overlay extends java.lang.Thread {
private static final java.lang.String THREAD_NAME = "Overlay";
private boolean changedSize;
private boolean hasValidDimensions;
private final android.graphics.Matrix matrix;
private float matrixScaleFactor;
private android.graphics.Bitmap overlayBitmap1;
private android.graphics.Bitmap overlayBitmap2;
private final android.graphics.Canvas overlayCanvas;
private final android.graphics.Point point;
private android.graphics.Point positionAfterDraw;
private android.graphics.Point positionBeforeDraw;
private boolean redraw;
protected org.mapsforge.android.maps.MapView internalMapView;

protected Overlay() { /* compiled code */ }

public final void draw(android.graphics.Canvas canvas) { /* compiled code */ }

public final void matrixPostScale(float scaleX, float scaleY, float pivotX, float pivotY) { /* compiled code */ }

public final void matrixPostTranslate(float translateX, float translateY) { /* compiled code */ }

public boolean onLongPress(org.mapsforge.core.GeoPoint geoPoint, org.mapsforge.android.maps.MapView mapView) { /* compiled code */ }

public final void onSizeChanged() { /* compiled code */ }

public boolean onTap(org.mapsforge.core.GeoPoint geoPoint, org.mapsforge.android.maps.MapView mapView) { /* compiled code */ }

public final void requestRedraw() { /* compiled code */ }

public final void run() { /* compiled code */ }

public final void setupOverlay(org.mapsforge.android.maps.MapView mapView) { /* compiled code */ }

private void redrawOverlay() { /* compiled code */ }

protected abstract void drawOverlayBitmap(android.graphics.Canvas canvas, android.graphics.Point point, org.mapsforge.android.maps.Projection projection, byte b);

protected java.lang.String getThreadName() { /* compiled code */ }

final void changeSize() { /* compiled code */ }

boolean sizeHasChanged() { /* compiled code */ }

protected static final enum EventType {
    public static final  LONG_PRESS, public static final  TAP;

    public static org.mapsforge.android.maps.overlay.Overlay.EventType[] values() { /* compiled code */ }

    public static org.mapsforge.android.maps.overlay.Overlay.EventType valueOf(java.lang.String name) { /* compiled code */ }

    private EventType() { /* compiled code */ }
}
}
4

1 回答 1

3

使用以下代码作为示例:

Point screenPts = new Point();

@Override
protected void drawOverlayBitmap(Canvas canvas, Point point, 
                  Projection projection, byte zoom){

        projection.toPixels(new GeoPoint((int)(location.getLatitude()*1E6),
                  (int)(location.getLongitude()*1E6)) , screenPts);
        canvas.drawBitmap(myBitmap, screenPts.x, screenPts.y, new Paint());
}

问候。

于 2012-11-20T23:35:24.490 回答