Tra*_*ieu 6 android google-maps markerclusterer google-maps-android-api-2
我正在使用谷歌地图,里面实现了聚类标记.但是,我的标记已被用户的当前位置图标覆盖,如下图所示
这是我的代码:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是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" />
Run Code Online (Sandbox Code Playgroud)
我希望我的标记应覆盖用户的当前位置图标.有谁能够帮我?
根据用户的标记,我假设您使用
mGoogleMap.setMyLocationEnbladed(true)
Run Code Online (Sandbox Code Playgroud)
方法。
根据您的结果,我认为 googleMap 在簇标记之后绘制 myLocation 标记。
也许解决方案是为 myLocation 绘制您的个人标记,因此,不要使用 setMyLocationEnabled() 方法,而是使用 onLocationChanged 方法绘制您自己的标记。
我觉得做自己想做的事情真的很难。正如我所说,GoogleMap 在之前的基础上绘制了标记。即使您在簇之前绘制 myLocation 标记,下一个 mylocation 也将位于您的簇上方,因此您需要重新绘制簇。
另一种方法可能是使用 Alpha(或透明度)绘制标记。
最后一件事,当用户位于集群下方时,为什么要隐藏用户的位置?
| 归档时间: |
|
| 查看次数: |
604 次 |
| 最近记录: |