gpt4 book ai didi

安卓谷歌地图 : How to calculate the distance between the middle of the screen/map and the top of the screen

转载 作者:行者123 更新时间:2023-11-29 01:31:21 25 4
gpt4 key购买 nike

我正在尝试计算从屏幕/ map (显示)中间到屏幕顶部的距离。我有某种算法可以执行此操作,但我不确定它是否正常工作。我收到 6367 及以上的数字。这是我的算法:

    double Radius = 6367.45;
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;

LatLng center = bounds.getCenter();
LatLng north = bounds.northeast;

// Convert lat or lng from decimal degrees into radians (divide by 57.2958)
double centerLat = center.latitude / 57.2958;
double centerLong = center.longitude / 57.2958;
double northLat = north.latitude / 57.2958;
double northLong = north.longitude / 57.2958;

// distance = circle radius from center to top of the screen
// this I ma not sure if it returns true numbers like amm real distance
// and I call it in the setOnCameraChangeListener on every zoom right?
// yes
boundRadius = Radius*(Math.acos(Math.sin(centerLat) * Math.sin(northLat) + Math.cos(centerLat)*Math.cos(northLat)*Math.cos(northLong - centerLong)));

我计算正确吗?如果不是,我做错了什么?

最佳答案

你可以只使用distanceBetween() (documentation) .我相信它考虑了地球的曲率。

关于安卓谷歌地图 : How to calculate the distance between the middle of the screen/map and the top of the screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31046951/

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