Search code examples
javaandroidopenstreetmaposmdroid

Adding a popup/snippet/title on top of the marker in my custom OSM map


I need to add a popup which displays city name (own description) on top of my added marker, below is my marker code. Any help will be appreciated.

private MapView osm;
osm = (MapView) findViewById(R.id.mapView);

    public void addMarker() {

            GeoPoint colombo = new GeoPoint(6.9271, 79.8612);

            Marker startMarker = new Marker(osm);
            startMarker.setPosition(colombo);
            osm.getOverlays().add(startMarker);
            startMarker.setIcon(getResources().getDrawable(R.drawable.black));
    }

Solution

  • startMarker.setTitle("title") should do the job... you can manually show it by calling showInfoWindow() method on the startMarker.

    If you want to have your own layout of the popup, you can subclass InfoWindow.