gpt4 book ai didi

java - 仅当建筑物完全位于cameraView内时才显示GroundOverlay

转载 作者:太空宇宙 更新时间:2023-11-04 09:01:55 25 4
gpt4 key购买 nike

如标题所述,本质上我只想在相机位于整个建筑物视野中时显示 GroundOverlay。我如何在 onCameraMove() 方法中完成此操作?截至目前,即使建筑物的部分位于相机 View 内,也会出现叠加层。

@Override
public void onCameraMove(){
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
private static final LatLng Building1 = new LatLng(54.69726685890506,-2.7379201682812226);

if(mMap.getCameraPosition().zoom > 17){
if (bounds.contains(Building1)) {
displayOverlay();
}
}

最佳答案

似乎 Building1 应该是建筑物边界点的列表,您应该在循环中检查所有这些点是否都包含在 bounds 中:

...
List<LatLng> buildingPoints = new ArrayList<>();
buildingPoints.add(new LatLng(...,...))
buildingPoints.add(new LatLng(...,...))
...

...
if(mMap.getCameraPosition().zoom > 17){
boolean allPointsVisible = true;
for (LatLng currBuildingPoint: buildingPoints) {
if (!bounds.contains(currBuildingPoint)) {
allPointsVisible = false;
break;
}
}
if (allPointsVisible) {
displayOverlay();
}
}
...

关于java - 仅当建筑物完全位于cameraView内时才显示GroundOverlay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60712693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com