Android(安卓)GPS坐标距离计算
Android GPS坐标距离计算
Android API :
Android API--Location
http://androiddoc.qiniudn.com/reference/android/location/Location.htm
public float distanceTo (Location dest)
Added in API level 1
Returns the approximate distance in meters between this location and
the given location. Distance is defined using the WGS84 ellipsoid.Parameters dest the destination location Returns • the approximate
distance in meters
API截图
Location
Location API 接口
http://androiddoc.qiniudn.com/reference/android/location/Location.html
百度地图API:
百度地图API截图 百度地图API截图static double getDistance(LatLng p1LL, LatLng p2LL)
返回两个点之间的距离
示例代码:
两种计算方式精确度对比:
LatLng latLng1 = new LatLng(37.014232, 117.565597);LatLng latLng2 = new LatLng(31.137012, 121.345326);double mDistance = DistanceUtil.getDistance(latLng1, latLng2);Log.e(TAG, "onCreate: 百度-距离:" + mDistance + "米");Location location1 = new Location("l1");location1.setLatitude(37.014232);location1.setLongitude(117.565597);Location location2 = new Location("l2");location2.setLatitude(31.137012);location2.setLongitude(121.345326);
07-08 10:17:47.678 27561-27561/baidumapsdk.demo E/MainActivity:
onCreate: 百度-距离:740275.3203764297米 07-08 10:17:47.678
27561-27561/baidumapsdk.demo E/MainActivity:
onCreate: 谷歌-距离:740275.3203764297米
更多相关文章
- Android(安卓)Button example
- 记事本。 layout相关
- Android(安卓)获取屏幕高宽度,密度,通知栏高度,截图等常用方法
- android控件常用属性区别
- android listview 自定义分割线总结
- Android图形层叠 – Layer-list
- 20155323 第四次实验 Android程序设计实验报告
- 百度地图申请密钥Android(安卓)SDK
- 利用百度词典API和Volley网络库开发的android词典应用