android map (google map ,百度 ,高德 )在路线 上画箭头
来源:互联网 发布:淘宝认证照片 编辑:程序博客网 时间:2024/06/18 09:56
android map (google map ,百度 ,高德 )在路线 上画箭头!
其实分为2步骤: 算角度,画箭头marker ,marker 画在路线两个点的中点
public void drawArrow(List<LatLng> list) { LogUtils.show(TAG, "开始画箭头"); if (list == null || list.size() <= 1) { LogUtils.show(TAG, "开始画箭头------失败"); return; } LogUtils.show(TAG, "开始画箭头------失满足条件"); for (int i = 1; i < list.size(); i++) { double lat1 = list.get(i - 1).latitude; double lng1 = list.get(i - 1).longitude; double lat2 = list.get(i).latitude; double lng2 = list.get(i).longitude; double lat = (lat1 + lat2) / 2; double lng = (lng1 + lng2) / 2; LatLng modLat = new LatLng(lat, lng); double brng = computeAzimuth(new LatLng(lat1, lng1), new LatLng(lat2, lng2)); MarkerOptions marker = new MarkerOptions().position(modLat); marker.anchor(0.5f, 0.5f); marker.icon(BitmapDescriptorFactory.fromResource(R.mipmap.line_arrow)); marker.rotation((float) brng); marker.flat(true); mMap.addMarker(marker); LogUtils.show(TAG, "开始画箭头------箭头-- " + i + "角度为 " + brng); }}// 计算方位角,正北向为0度,以顺时针方向递增private double computeAzimuth(LatLng la1, LatLng la2) { double lat1 = la1.latitude, lon1 = la1.longitude, lat2 = la2.latitude, lon2 = la2.longitude; double result = 0.0; int ilat1 = (int) (0.50 + lat1 * 360000.0); int ilat2 = (int) (0.50 + lat2 * 360000.0); int ilon1 = (int) (0.50 + lon1 * 360000.0); int ilon2 = (int) (0.50 + lon2 * 360000.0); lat1 = Math.toRadians(lat1); lon1 = Math.toRadians(lon1); lat2 = Math.toRadians(lat2); lon2 = Math.toRadians(lon2); if ((ilat1 == ilat2) && (ilon1 == ilon2)) { return result; } else if (ilon1 == ilon2) { if (ilat1 > ilat2) result = 180.0; } else { double c = Math .acos(Math.sin(lat2) * Math.sin(lat1) + Math.cos(lat2) * Math.cos(lat1) * Math.cos((lon2 - lon1))); double A = Math.asin(Math.cos(lat2) * Math.sin((lon2 - lon1)) / Math.sin(c)); result = Math.toDegrees(A); if ((ilat2 > ilat1) && (ilon2 > ilon1)) { } else if ((ilat2 < ilat1) && (ilon2 < ilon1)) { result = 180.0 - result; } else if ((ilat2 < ilat1) && (ilon2 > ilon1)) { result = 180.0 - result; } else if ((ilat2 > ilat1) && (ilon2 < ilon1)) { result += 360.0; } } return result;}
阅读全文
0 0
- android map (google map ,百度 ,高德 )在路线 上画箭头
- android 在map上画出路线
- Android 在map上画出路线
- 在Google Map的地图轨迹上添加箭头
- android google map路线 画图等方法
- Android上使用Google Map
- Android上使用Google Map
- Android 用map上画出路线
- 关于百度map和高德map,关于map坐标系
- 关于百度map和高德map,关于map坐标系
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- android在google map上画出导航路线图
- 【分治】化装晚会
- 常用正则表达式
- hql-行列转换
- python编码声明:是coding:utf-8还是coding=utf-8
- RMAN_详解与实例
- android map (google map ,百度 ,高德 )在路线 上画箭头
- 打洞原理及应用
- Scikit-Learn各算法详细参数速查手册(中文)
- kubernetes:kubedns安装
- 解决 eclipse runtime 找不到 tomcat (图文)
- 升级Ubuntu系统
- 包容性
- Oracle学习系列之Rman学习(三)
- 为什么需要有JavaScript