我目前正在测试这里的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
}
}
答案 0 :(得分:5)
主要问题是Here SDK合并方法返回一个新的geoBounding框,而不是将旧值设置为旧值。所以主要的变化是:
geoBoundingBox = geoBoundingBox.merge(new GeoBoundingBox(coordinate, coordinate));
答案 1 :(得分:1)
看起来您正在尝试将初始空边界框与奇点合并?
最好是从包含前两个标记的边界框开始,然后展开它以适应其他Geocoordinate。