【发布时间】:2015-01-02 03:08:46
【问题描述】:
我在尝试自定义 Google 地图上的聚集标记时遇到了一些麻烦。我正在使用 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;
}
}
所以基本上使用这些代码,它只会在地图上显示一个红色标记。我想知道如何使用自己的图像自定义标记。我知道您可以这样做来自定义地图上的标记:
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
但我不确定在这种情况下如何实现它。有指南吗?
提前致谢。
【问题讨论】:
-
有什么指南吗?我被卡住了
标签: java android google-maps google-maps-api-3