如何验证纬度和经度经度、纬度

2023-09-07 05:02:24 作者:我不快乐

我有两个 UITextFields,用户可以输入纬度和经度,然后使用这些坐标在 MKMapView 上创建图钉.

I have two UITextFields which users can enter in a latitude and longitude, these co-ordinates are then used to create a pin on an MKMapView.

我想找到一种方法来验证他们输入的值是实际的 GPS 坐标还是只是一堆垃圾.有没有办法做到这一点?

I want find a way to validate whether the values they enter are actual GPS co-ordinates or just a load of rubbish. Is there any way of doing this?

推荐答案

纬度必须是介于-90 和 90 以及 经度 在 -180 和 180 之间.

The latitude must be a number between -90 and 90 and the longitude between -180 and 180.

 
精彩推荐
图片推荐