我目前正在测试适用于 Android 的 Here Maps SDK。我有一组标记,我需要能够放大以便它们都适合屏幕。我目前尝试使用 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
}
}
最佳答案
主要问题是 Here SDK 合并方法返回一个新的 geoBounding 框,而不是将新值设置为旧值。所以主要的变化是:
geoBoundingBox = geoBoundingBox.merge(new GeoBoundingBox(coordinate, coordinate));
关于android - 这里 SDK Android 缩放到几个标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37074460/