【发布时间】:2017-03-08 08:14:21
【问题描述】:
我正在使用在内部实现聚类标记的谷歌地图。但是,我的标记已被用户的当前位置图标覆盖,如下图
这是我的代码:
protected void onBeforeClusterRendered(Cluster<CurationLocation> cluster, MarkerOptions markerOptions) {
if (isAdded()) {
final Drawable clusterIcon = getResources().getDrawable(R.drawable.oval_bg);
mClusterIconGenerator.setBackground(clusterIcon);
mClusterIconGenerator.setTextAppearance(R.style.AppTheme_WhiteTextAppearance);
LayoutInflater myInflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View clusterView = myInflater.inflate(R.layout.customize_cluster_layout, null, false);
mClusterIconGenerator.setContentView(clusterView);
final Bitmap icon = mClusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
} else {
return;
}
}
这是 XML 部分:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/text"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="@drawable/icon_location_clustering"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:text="33"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textSize="13sp" />
我希望我的标记覆盖用户的当前位置图标。有人可以帮帮我吗?
【问题讨论】:
-
我的位置图层绘制在地图顶部,因此您需要实现自己的位置图层以避免将其显示在顶部。看看stackoverflow.com/questions/33411112/…
-
感谢您的快速回答。我仍然不知道如何将您的类实现到我的源代码中
标签: android google-maps google-maps-android-api-2 markerclusterer