문제

Using the nice / new osmbonuspack package:

Is there a way to show the name (or title) of the Marker immediately on the Map?

So, without tapping the Marker.

도움이 되었습니까?

해결책

Thank you, MKer, for extending the class.

Below, this is my implementation showing text on the Map. Hope this helps others.

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); 
 }
}

In the code you could add:

marker = new MarkerWithLabel( mv, label);
marker.setTitle( label); 
etc

다른 팁

Of course! Very easy:

myMarker.showInfoWindow();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top