赞
踩
通过高德导航位置信息的回调, 在规划路线上获取道路信息, 以及道路拥堵状态。
@Override public void onLocationChange(AMapNaviLocation aMapNaviLocation) { int curStepIndex = aMapNaviLocation.getCurStepIndex(); int curLinkIndex = aMapNaviLocation.getCurLinkIndex(); List<AMapNaviStep> steps = mAMapNavi.getNaviPath().getSteps(); AMapNaviStep aMapNaviStep = steps.get(curStepIndex); List<AMapNaviLink> links = aMapNaviStep.getLinks(); if(links != null && links.size() > 0) { AMapNaviLink link = links.get(curLinkIndex); String roadName = link.getRoadName(); int roadType = link.getRoadType(); int roadClass = link.getRoadClass(); int linkType = link.getLinkType(); int trafficStatus = link.getTrafficStatus(); Log.e("888", "name : " + roadName + " | roadType : " + getRoadType(roadType) + " | roadclass : " + getRoadClass(roadClass) + " | linkType : " + getLinkType(linkType) + " | trafficState : " + getTrafficState(trafficStatus)); } } public String getRoadClass (int roadClass) { String roadClassStr = ""; switch (roadClass) { case 0: roadClassStr = "高速公路"; break; case 1: roadClassStr = "国道"; break; case 2: roadClassStr = "省道"; break; case 3: roadClassStr = "乡道"; break; case 4: roadClassStr = "乡公路"; break; case 5: roadClassStr = "县乡村内部道路"; break; case 6: roadClassStr = "主要大街、城市快速道"; break; case 7: roadClassStr = "主要道路"; break; case 8: roadClassStr = "次要道路"; break; case 9: roadClassStr = "普通道路"; break; case 10: roadClassStr = "非导航道路"; break; default: roadClassStr = "未知"; break; } return roadClassStr; } public String getRoadType(int roadType) { String roadTypeStr = ""; switch (roadType) { case 1: roadTypeStr = "主路"; break; case 2: roadTypeStr = "路口内部道路"; break; case 3: roadTypeStr = "JCT道路"; break; case 4: roadTypeStr = "环岛"; break; case 5: roadTypeStr = "服务区"; break; case 6: roadTypeStr = "匝道"; break; case 7: roadTypeStr = "辅路"; break; case 8: roadTypeStr = "匝道与JCT"; break; case 9: roadTypeStr = "出口"; break; case 10: roadTypeStr = "入口"; break; case 11: roadTypeStr = "A类右转专用道"; break; case 12: roadTypeStr = "B类右转专用道"; break; case 13: roadTypeStr = "A类左转专用道"; break; case 14: roadTypeStr = "B类左转专用道"; break; case 15: roadTypeStr = "普通道路"; break; case 16: roadTypeStr = "左右转专用道"; break; case 17: roadTypeStr = "非机动车借道路"; break; case 56: roadTypeStr = "服务区与匝道"; break; case 53: roadTypeStr = "服务区与JCT"; break; case 58: roadTypeStr = "服务区与匝道以及JCT"; break; default: roadTypeStr = "未知"; break; } return roadTypeStr; } public String getLinkType(int linkType) { String linkTypeStr = ""; switch (linkType) { case 0: linkTypeStr = "普通道路"; break; case 1: linkTypeStr = "航道"; break; case 2: linkTypeStr = "隧道"; break; case 3: linkTypeStr = "桥梁"; break; default: linkTypeStr = "未知"; break; } return linkTypeStr; } public String getTrafficState(int trafficState) { String trafficStateStr = ""; switch (trafficState) { case 0: trafficStateStr = "未知状态"; break; case 1: trafficStateStr = "畅通"; break; case 2: trafficStateStr = "缓行"; break; case 3: trafficStateStr = "阻塞"; break; default: trafficStateStr = "严重阻塞"; break; } return trafficStateStr; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。