Question

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.

Was it helpful?

Solution

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

OTHER TIPS

Of course! Very easy:

myMarker.showInfoWindow();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top