Ale*_*Ale 22 android google-maps distance google-maps-android-api-2
我想在地图上画一个静态圆圈Google Maps.当用户捏住时,地图将放大/缩小.
我需要知道地图半径(与圆圈中包含的区域相关)并相应地更改底部的搜索条.
有人知道如何检索从左边到右边屏幕边缘的距离吗?我没有在Google Maps API文档中找到任何内容.
像这样的东西:

Md.*_*moy 41
使用VisibleRegion,您可以获得所有角落坐标以及中心.
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
double left = vr.latLngBounds.southwest.longitude;
double top = vr.latLngBounds.northeast.latitude;
double right = vr.latLngBounds.northeast.longitude;
double bottom = vr.latLngBounds.southwest.latitude;
Run Code Online (Sandbox Code Playgroud)
并且你可以通过这个来计算两个区域的距离
Location MiddleLeftCornerLocation;//(center's latitude,vr.latLngBounds.southwest.longitude)
Location center=new Location("center");
center.setLatitude( vr.latLngBounds.getCenter().latitude);
center.setLongitude( vr.latLngBounds.getCenter().longitude);
float dis = center.distanceTo(MiddleLeftCornerLocation);//calculate distane between middleLeftcorner and center
Run Code Online (Sandbox Code Playgroud)

Fer*_*Fer 12
我有一段时间在@Md给出的最佳答案中编写"MiddleLeftCornerLocation"变量的代码.Monsur Hossain Tonmoy,所以只是为了完成它(我没有足够的声誉点来评论你的答案,对不起):
VisibleRegion vr = map.getProjection().getVisibleRegion();
double bottom = vr.latLngBounds.southwest.latitude;
Location center = new Location("center");
center.setLatitude(vr.latLngBounds.getCenter().latitude);
center.setLongitude(vr.latLngBounds.getCenter().longitude);
Location middleLeftCornerLocation = new Location("center");
middleLeftCornerLocation.setLatitude(center.getLatitude());
middleLeftCornerLocation.setLongitude(left);
float dis = center.distanceTo(middleLeftCornerLocation);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8396 次 |
| 最近记录: |