gpt4 book ai didi

android - 如何在Android Google Maps中获取距指定点(Lat,Lng)X距离的纬度,经度

转载 作者:可可西里 更新时间:2023-11-01 11:42:45 26 4
gpt4 key购买 nike

假设我给了一个点(纬度,经度)和一个距离,如何在Android谷歌地图中得到在四个方向上指定距离的另一个点?

示例我给出一个点 LatLng(X,Y) 和一个 10 英里的距离。我应该在给定距离内的所有四个方向(NORTH,SOUTH,EAST,WEST)接收四个点。

最佳答案

使用 Google Maps Android API Utility Library您可以使用 SphericalUtil.computeOffset 方法。来自 the documentation :

public static LatLng computeOffset(LatLng from,
double distance,
double heading)

Returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north).

Parameters:

  • from - The LatLng from which to start.
  • distance - The distance to travel.
  • heading - The heading in degrees clockwise from north.

在您的情况下,您将需要使用四个标题:0 代表 NORTH,90 代表 EAST,180 代表 SOUTH,270 代表 WEST。

另外,请注意距离参数以米为单位。

关于android - 如何在Android Google Maps中获取距指定点(Lat,Lng)X距离的纬度,经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35592054/

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