我正在尝试使用mapsforge映射库在Android上的地图上叠加位图。我正在扩展Overlay类,我需要实现drawOverlayBitmap。有没有人知道如何做到这一点?我用谷歌搜索了,但所有的结果都是使用google的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 */ }
}
}
答案 0 :(得分: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());
}
问候。