gpt4 book ai didi

java - Android 集群 map 更改标记

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:59 25 4
gpt4 key购买 nike

我在尝试自定义 Google map 上的集群标记时遇到了一些麻烦。我正在使用 Google Map Android API 库和来自 GoogleMap Documentation 的引用资料.这是我的代码:

private void setUpClusterer() {
googleBasemap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
1.379348, 103.849876), 11.0f));
mClusterManager = new ClusterManager<EventClusterItem>(this,
googleBasemap);
googleBasemap.setOnCameraChangeListener(mClusterManager);
googleBasemap.setOnMarkerClickListener(mClusterManager);
addItems();
}

private void addItems() {
for (int i = 0; i < convertedGeomList.size(); i++) {
EventClusterItem offsetItem = new EventClusterItem(convertedGeomList.get(i)
.getY(), convertedGeomList.get(i).getX());
mClusterManager.addItem(offsetItem);
}
}

还有我的 EventClusterItem 类:

public class EventClusterItem implements ClusterItem {
private final LatLng mPosition;

public EventClusterItem(double lat, double lng) {
mPosition = new LatLng(lat, lng);
}

public LatLng getPosition() {
return mPosition;
}
}

所以基本上使用这些代码,它只会在 map 上显示一个红色标记。我想知道如何使用我自己的图像自定义标记。我知道您可以这样做来自定义 map 上的标记:

Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

但我不确定在这种情况下如何实现。有什么指南吗?

提前致谢。

最佳答案

使用这些帖子的答案:

How to set my own icon for markers in clusterer in Google Maps

How to add title, snippet and icon to ClusterItem?

没有关于此 API 的任何指南。您应该找到该库的代码并尝试理解它 - 它很简单,代码很完美(但实际上有点慢)。

关于java - Android 集群 map 更改标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com