【问题标题】:Android cluster map change markerAndroid集群地图更改标记
【发布时间】: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


【解决方案1】:

使用这些帖子的答案:

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

How to add title, snippet and icon to ClusterItem?

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-18
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-27
    相关资源
    最近更新 更多