Android Here SDK 如何缩放多个地图标记?

3

我目前正在测试Here Maps SDK for Android。我有一组标记,需要能够缩放以适应屏幕。我尝试使用GeoBoundingBox,但必须同时插入2个位置(角落)。搜索了文档,但没有找到相关信息。是否可能,我该怎么做?

我如何尝试做到这一点

 GeoBoundingBox geoBoundingBox = hereMap.getBoundingBox();
    if (data != null && data.getItemGroups() != null) {
        for (ItemGroup itemGroup: data.getItemsGroups()) {
            ClusterLayer clusterLayer = new ClusterLayer();
            for (Item item : itemGroup.getItems()) {
                if (item != null && item.isLatLngOk()) {
                    GeoCoordinate coordinate = new GeoCoordinate(item .getLat(), item .getLng());
                    clusterLayer.addMarker(new MapMarker(coordinate, image));
                    geoBoundingBox.merge(new GeoBoundingBox(coordinate, coordinate));
                }
            }
            hereMap.addClusterLayer(clusterLayer);
            hereMap.zoomTo(geoBoundingBox, Map.Animation.LINEAR, 0); // This does not work
        }
    }

请注意为什么问题被投票降低。谢谢。 - Arūnas Bedžinskas
2个回答

5
主要问题是Here SDK合并方法返回一个新的地理边界框,而不是将新值设置到旧的边界框中。因此,主要更改为:
geoBoundingBox = geoBoundingBox.merge(new GeoBoundingBox(coordinate, coordinate));

1

看起来你正在尝试合并一个初始的空边界框和一个奇点?

最好的方法是从由前两个标记组成的边界框开始,然后扩展它以适应其他地理坐标。


请在添加每个点后打印出边界框的topLeft()和bottomRight()。这样可以让您知道问题所在。 - David Leong
谢谢,你的回答确实有帮助。虽然主要问题不同。 - Arūnas Bedžinskas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接