Osmbonuspack:在地图上显示Marker的名称

tm1*_*701 1 android osmdroid

使用nice/new osmbonuspack包:

有没有办法在地图上立即显示标记的名称(或标题)?

所以,不要点击标记.

tm1*_*701 6

谢谢你,MKer,扩展课程.

下面,这是我在地图上显示文字的实现.希望这有助于其他人.

public class MarkerWithLabel extends Marker {
Paint textPaint = null; 
String mLabel = null; 

public MarkerWithLabel(MapView mapView, String label) {
    super( mapView);
    mLabel = label; 
    textPaint = new Paint();
    textPaint.setColor( Color.RED);
    textPaint.setTextSize(40f);
    textPaint.setAntiAlias(true);
    textPaint.setTextAlign(Paint.Align.LEFT);
}
public void draw( final Canvas c, final MapView osmv, boolean shadow) {
    draw( c, osmv); 
}
public void draw( final Canvas c, final MapView osmv) {
    super.draw( c, osmv, false); 
    Point p = this.mPositionPixels;  // already provisioned by Marker
    c.drawText( mLabel, p.x, p.y+20, textPaint); 
 }
}
Run Code Online (Sandbox Code Playgroud)

在您可以添加的代码中:

marker = new MarkerWithLabel( mv, label);
marker.setTitle( label); 
etc
Run Code Online (Sandbox Code Playgroud)