且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用当前位置和半径获得最小和最大纬度和经度?

更新时间:2023-08-30 12:19:46

您可以手动计算它...我不知道是否存在任何其他方式
1°纬度= 69.047法定里程= 60海里
= 111.12公里

you can manually calculate it... I don't know if any other way exist 1° latitude = 69.047 statute miles = 60 nautical miles = 111.12 kilometers

因此对于20公里,它将是大约0.18纬度
对于经度,转换与纬度相同,除了该值乘以纬度的余弦。

so for 20 kilometers it would be around 0.18 latitude For longitude the conversion is the same as latitude except the value is multiplied by the cosine of the latitude.

在地图上设置相同的范围以供显示

To set the same range on map for display

newRegion.center=newLocation.coordinate;
    //  newRegion.span.latitudeDelta = (20*2)/111.12;   // For kilometers

    newRegion.span.latitudeDelta = (20*2)/60.0; // For Miles
    newRegion.span.longitudeDelta = ((20*2)/60.0) *(cos(newRegion.span.latitudeDelta)); // For Miles
    mapView.region = newRegion;

它将在显示的地图上设置20公里的范围......

It will set 20 kilometer's range on map that is displayed...

所以你可以找到它

你可以找到它

minLattitude = currentLattitude - (RadiusInKm/111.12);
maxLattitude = currentLattitude + (RadiusInKm/111.12);

对于经度相同但乘以纬度余弦的结果......

For longitude same but multiply the result with cosine of latitude...