I am using maps in Android provided by MapQuest, but implemented in the same way as Google Maps so the same question applies.
For the overlay item, I would like to use a layout with an ImageView and TextView as the TextView will be displaying some information. The problem is I can only seem to show a drawable as my overlay which must come from the Drawable folder.
Here is the code for adding the overlay item:
private void loadSingleOverlay(TapControlledMap mapViewPassed, String title, String address)
{
Drawable icon = getResources().getDrawable(R.drawable.marker2);
OverlayItem newItem = new OverlayItem(point, title, address);
overlay = new ExtendedItemizedOverlay(icon);
overlay.addItem(newItem);
// add a tap listener
overlay.setTapListener(tapListener);
List<Overlay> listOfOverlays = mapViewPassed.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(overlay);
mapViewPassed.invalidate();
}
And the layout I want to inflate and use:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/marker_red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1" />
</RelativeLayout>
Here is the result I am going for:
Thanks all