Search code examples
androidosmdroid

Marker not showing in osmdroid


I want to add a draggable marker to osmdroid. for that I use this code

    import org.osmdroid.views.overlay.Marker;

    Marker marker=new Marker(mapView);
    marker.setPosition(new GeoPoint(36.607007, 59.133225));
    marker.setIcon(drawable);
    marker.setImage(drawable);
    marker.setTitle("dddd");  
    marker.showInfoWindow();

it dosent show my icon in mapview but just show info window.
can anyone help me about that?


Solution

  • You need to add marker to Overlays and invalidate your mapView.

    Try with adding marker to Map Overlays and calling mapView.invalidate() like below.

    Marker marker=new Marker(mapView);
    marker.setPosition(new GeoPoint(36.607007, 59.133225));
    marker.setIcon(drawable);
    marker.setImage(drawable);
    marker.setTitle("dddd");  
    marker.showInfoWindow();
    mapView.getOverlays().add(marker);
    mapView.invalidate();