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:

static double getDistance(LatLng p1LL, LatLng p2LL)
返回两个点之间的距离

百度地图API截图 百度地图API截图

示例代码:

两种计算方式精确度对比:

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米

更多相关文章

  1. Android(安卓)Button example
  2. 记事本。 layout相关
  3. Android(安卓)获取屏幕高宽度,密度,通知栏高度,截图等常用方法
  4. android控件常用属性区别
  5. android listview 自定义分割线总结
  6. Android图形层叠 – Layer-list
  7. 20155323 第四次实验 Android程序设计实验报告
  8. 百度地图申请密钥Android(安卓)SDK
  9. 利用百度词典API和Volley网络库开发的android词典应用

随机推荐

  1. android 系统定制之编译方法总结
  2. 解决 maven { url 'https://maven.google
  3. android OpenGLES开发第三课 绘制一个可
  4. Android(安卓)Studio更新3.1后报错
  5. Android(安卓)4.0 ICS SystemUI浅析——S
  6. android实现短信监听
  7. Android自定义dialog主题样式解析
  8. Android中GridView实现长按多选功能
  9. Android原生音量控制
  10. android 使用InstanceState保存和恢复数