سؤال

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