We use the high-level map SDK after the path planning, in addition to adding lines to the map, often also need to get the detailed description of the route, such as the length of the route, the time required, the route of each section of the situation, such as the height of the map:
We have a simple answer to this function, the First Bus line query (unclear classmate can see the demo), in the query results processed:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
if (busRouteResult !=
null && busRouteResult.getPaths() !=
null
&& busRouteResult.getPaths().size() >
0
) {
// 以推荐线路的第一条数据为例进行处理
BusPath busPath = busRouteResult.getPaths().get(
0
);
// 分别获取公交线路距离,步行距离,整个线路距离
String routeInfo =
"公交路线长度:" + busPath.getBusDistance()
+
" 步行 长度" + busPath.getWalkDistance() +
" 线路长度:"
+ busPath.getDistance() +
"\n"
;
List<BusStep> busSteps = busPath.getSteps();
// 获取每一段换乘所需的步行距离,起始终止站点,经过的站数(不包括起始和终点站),距离和所需时间
for (BusStep busStep : busSteps) {
if (busStep.getWalk() !=
null
) {
RouteBusWalkItem walkPath = busStep.getWalk();
routeInfo = routeInfo +
"需要步行大约"
+ Math.round(walkPath.getDuration() /
60
)
+
"分钟,步行" + walkPath.getDistance() +
"米\n"
;
}
if (busStep.getBusLine() !=
null
) {
RouteBusLineItem busLineItem = busStep.getBusLine();
routeInfo = routeInfo
+
"乘坐"
+ busLineItem.getBusLineName()
+
"需要大约"
+ Math.round(busLineItem.getDuration() /
60
)
+
"分钟,大约"
+ busLineItem.getDistance()
+
"米,经过"
+ busLineItem.getPassStationNum()
+
"站,从"
+ busLineItem.getDepartureBusStation()
.getBusStationName()
+
"上车,从"
+ busLineItem.getArrivalBusStation()
.getBusStationName() +
"下车\n"
;
}
}
mRouteInfoText.setText(routeInfo);
|
The effect is as follows:
You can also get detailed information on walking and driving directions. Specific code (replace key) and apk see attachment