gpt4 book ai didi

android - 给定中心和半径,如何在 Google map 中获取圆的 LatLngBounds?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:06 24 4
gpt4 key购买 nike

如何获得具有给定圆心和半径的圆的东北坐标和西南坐标?我无法在任何地方找到任何解决方案。目前,Circle 对象不像以前那样有 getLatLngBounds() 和 getBounds() 方法。

最佳答案

您可以使用 SphericalUtil.computeOffset 方法 Google Maps Android API Utility Library .要使用它,您需要对 build.gradle 具有以下依赖性:

dependencies {
compile 'com.google.maps.android:android-maps-utils:0.4+'
}

然后,您可以计算圆的东北坐标和西南坐标:

double radius = 104.52;
LatLng center = new LatLng(40.22861, -3.95567);

LatLng targetNorthEast = SphericalUtil.computeOffset(center, radius * Math.sqrt(2), 45);
LatLng targetSouthWest = SphericalUtil.computeOffset(center, radius * Math.sqrt(2), 225);

关于android - 给定中心和半径,如何在 Google map 中获取圆的 LatLngBounds?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37303931/

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