android - Osmbonuspack : show name of Marker on the map

标签 android osmdroid

使用漂亮/新的 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/

相关文章:

android - org.osmdroid.DefaultResourceProxyTest 的 ParseException

android - 无法将我的位置叠加层添加到 osmdroid map

java.net.UnknownHostException : Unable to resolve host "api. themoviedb.org

android - 更改 Action Bar 中按钮的背景,Android

java - 获取二维数组中的 SQLite DB 数据并在 android 中返回

android - Osmdroid 和 Mapnik 瓦片供应商不再工作

java - 覆盖 OSMdroid 中的位置跟踪

android - OSMdroid : How to render offline map from a local zip archive

android - 标记错误地枚举为 MIFARE Classic,SAK = 32

android - 安卓市场商户账号