使用漂亮/新的 osmbonuspack 包:
有没有办法立即在 map 上显示标记的名称(或标题)?
因此,无需点击标记。
最佳答案
MKer,感谢您扩展类(class)。
下面,这是我在 map 上显示文本的实现。希望这对其他人有帮助。
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);
}
}
在代码中你可以添加:
marker = new MarkerWithLabel( mv, label);
marker.setTitle( label);
etc
关于android - Osmbonuspack : show name of Marker on the map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22250423/