I'm using google map that implemented Clustering marker inside. However, my markers has been overlaid by User's current location icon like Image below
这是我的代码:
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" />
我希望我的标记应该覆盖用户的当前位置图标。有谁能够帮助我?
根据用户的标记,我假设您使用
mGoogleMap.setMyLocationEnbladed(true)
method.
根据您的结果,我认为 googleMap 在簇标记之后绘制 myLocation 标记。
也许解决方案是为我的位置绘制您的个人标记,因此,不要使用 setMyLocationEnabled() 方法,而是使用您自己的 onLocationChanged 方法标记。
我觉得做自己想做的事情真的很难。正如我所说,GoogleMap 在之前的基础上绘制了标记。即使您在簇之前绘制 myLocation 标记,下一个 mylocation 也将位于您的簇上方,因此您需要重新绘制簇。
另一种方法可能是用 Alpha(或透明度)绘制标记。
最后一件事,当用户位于集群下方时,为什么要隐藏用户的位置?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)