我正在使用由MapQuest提供的Android地图,但实现方式与Google Maps相同,因此同样的问题适用。
对于叠加项,我想使用一个包含ImageView和TextView的布局,因为TextView将显示一些信息。问题在于,我似乎只能显示一个来自Drawable文件夹的可绘制对象作为我的叠加项。
这是添加叠加项的代码:
我希望的结果是这样的:
对于叠加项,我想使用一个包含ImageView和TextView的布局,因为TextView将显示一些信息。问题在于,我似乎只能显示一个来自Drawable文件夹的可绘制对象作为我的叠加项。
这是添加叠加项的代码:
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();
}
我想要加载并使用的布局:
<?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>
我希望的结果是这样的: