Gold Map ANDROIDSDK Route planning details get

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.