Search code examples
javaandroidandroid-mapviewopenstreetmaposmdroid

OSMDroid/OSMBonusPack adding marker with info bubble on marker click


I've written some simple code to add a mapview to my app and then add markers to the mapview. What I would like to happen is when the user taps on the marker it should bring up an information bubble with more information about the marker such as the marker title. I've found there isn't a huge amount of information on the internet about OSMDroid and I was wondering if anyone knows a simple way of doing this?

my code for adding a marker to my mapview:

            // create GeoPoint
            GeoPoint mGeoP = new GeoPoint(51.000000, -2.000000);

            // build a new marker pin
            Marker mPin = new Marker(mapView);
            mPin.setPosition(mGeoP);
            mPin.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
            mPin.setIcon(getResources().getDrawable(R.drawable.ic_green_pin2));
            mPin.setTitle("POINT");


            // add new marker pin to map
            mapView.getOverlays().add(mPin);
            mapView.invalidate();

Solution

  • Problem solved:
    Turns out i was missing the .XML and .PNG files needed to create the bubble!