Google Map V2 Android和iOS放置latlng小数位 [英] Google Map V2 Android and iOS place latlng decimal places
问题描述
这两个应用程序都使用谷歌的PlaceAutocomplete控制器来获取位置的经纬度。在iOS中,我们可以获得纬度长达6位小数位,有时候也是5位。在android中,我们得到6个以上的小数位。
例如,考虑位置Pune
Android Latlng:18.520431 ,73.856744
iOS Latlng:18.52043,73.856744
正如您所看到的,同样位置的纬度精度。
有没有办法避免这种情况,因为我的应用程序需要比较这些经纬度?
你不应该依靠坐标的精确度来比较它们,因为它们可以改变,或者,平台。
相反,您可以设置容差来确定两个位置是否相同。例如:
float YOUR_TOLERANCE = 1; // 1米
if(location.distanceTo(otherLocation)< YOUR_TOLERANCE){
//两个位置都被认为是相同的
}
There is an Android as well as iOS application that I am working on. Both the applications use google's PlaceAutocomplete controller to get a location's lat-long. In iOS we get lat-long upto 6 decimal places sometimes 5 also. Where as in android we get more than 6 decimal places. The precision of the same location coordinate for Android and iOS differs.
For example consider location Pune
Android Latlng: 18.520431,73.856744
iOS Latlng: 18.52043,73.856744
So as you can see there is difference between the precision of latitudes of the same location.
Is there a way to avoid this as my application needs comparison of these lat-longs?
You should not rely on the precision of the coordinates to compare them because they can change or, as you experiment, vary between platforms.
Instead, you can set a tolerance to determine if two locations are the same. For example:
float YOUR_TOLERANCE = 1; // 1 meter
if (location.distanceTo(otherLocation) < YOUR_TOLERANCE) {
// Both locations are considered the same
}
这篇关于Google Map V2 Android和iOS放置latlng小数位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!