谢谢你,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)
| 归档时间: |
|
| 查看次数: |
1313 次 |
| 最近记录: |