Using Android Osmdroid Bonuspack I created a Marker with a custom InfoWindow.
marker = new MarkerWithLabel( mv, mapDescription6);
marker.setTitle( description);
marker.setSubDescription( gcId);
marker.setPosition( gp);
marker.setIcon( bubble);
marker.setAnchor( 0.5f, 1.0f);
marker.setInfoWindow( new MapGeocacheAction( mv, this, gp, etc.));
In the InfoWindow I have a few buttons. When pressing one button, I would like to change the original Marker title (e.g. with a star behind then name).
How can I change the Marker title (real time) after clicking the button (so the InfoWindow is gone) to have a different name?
De MarkerWithLabel code is:
public class MarkerWithLabel extends Marker {
Paint textPaint;
String mLabel;
public MarkerWithLabel(MapView mv, String l) {
super( mv);
mLabel = l;
textPaint = new Paint();
textPaint.setColor( Color.RED);
textPaint.setTextSize( dim25sp);
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;
c.drawText( mLabel, p.x, p.y+20, textPaint);
}
}
EDIT using the solution from MKer:
1 - Getting the v5.1 version of Osmonuspack.
2 - In the WindowWindow add on a button click:
mMarkerRef.setTitle( title.substring( 2));
3 - In the MarkerWithLabel: use the title (not the label):
c.drawText( getTitle(), p.x, p.y+20, textPaint);
I assume your MapGeocacheAction inherits from MarkerInfoWindow.
MarkerInfoWindow keeps a handle to the Marker on which it has been opened, with mMarkerRef attribute. It is protected, so you have access to it in MapGeocacheAction.
So in your button click handler, before closing the window, you can set:
mMarkerRef.setTitle(newTitle);