设为首页 加入收藏

TOP

android studio高德地图的显示于定位(附带逆地理编码围栏)(五)
2017-10-12 10:04:01 】 浏览:8538
Tags:android studio 高德 地图 显示 定位 附带 地理 编码 围栏
tToLatLng(LatLonPoint latLonPoint) { return new LatLng(latLonPoint.getLatitude(), latLonPoint.getLongitude()); } /** * 把集合体的LatLonPoint转化为集合体的LatLng */ public static ArrayList<LatLng> convertArrList(List<LatLonPoint> shapes) { ArrayList<LatLng> lineShapes = new ArrayList<LatLng>(); for (LatLonPoint point : shapes) { LatLng latLngTemp = AMapUtil.convertToLatLng(point); lineShapes.add(latLngTemp); } return lineShapes; } /** * long类型时间格式化 */ public static String convertToTime(long time) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(time); return df.format(date); } public static final String HtmlBlack = "#000000"; public static final String HtmlGray = "#808080"; public static String getFriendlyTime(int second) { if (second > 3600) { int hour = second / 3600; int miniate = (second % 3600) / 60; return hour + "小时" + miniate + "分钟"; } if (second >= 60) { int miniate = second / 60; return miniate + "分钟"; } return second + "秒"; } public static String getBusPathTitle(BusPath busPath) { if (busPath == null) { return String.valueOf(""); } List<BusStep> busSetps = busPath.getSteps(); if (busSetps == null) { return String.valueOf(""); } StringBuffer sb = new StringBuffer(); for (BusStep busStep : busSetps) { if (busStep.getBusLines().size() > 0) { RouteBusLineItem busline = busStep.getBusLines().get(0); if (busline == null) { continue; } String buslineName = getSimpleBusLineName(busline.getBusLineName()); sb.append(buslineName); sb.append(" > "); } if (busStep.getRailway() != null) { RouteRailwayItem railway = busStep.getRailway(); sb.append(railway.getTrip() + "(" + railway.getDeparturestop().getName() + " - " + railway.getArrivalstop().getName() + ")"); sb.append(" > "); } } return sb.substring(0, sb.length() - 3); } public static String getBusPathDes(BusPath busPath) { if (busPath == null) { return String.valueOf(""); } long second = busPath.getDuration(); String time = getFriendlyTime((int) second); float subDistance = busPath.getDistance(); String subDis = getFriendlyLength((int) subDistance); float walkDistance = busPath.getWalkDistance(); String walkDis = getFriendlyLength((int) walkDistance); return String.valueOf(time + " | " + subDis + " | 步行" + walkDis); } public static String getSimpleBusLineName(String busLineName) { if (busLineName == null) { return String.valueOf(""); } return busLineName.replaceAll("\\(.*?\\)", ""); } }

  

Utils的主代码为:

public class Utils {


    /**
     * 开始定位
     */
    public final static int MSG_LOCATION_START = 0;
    /**
     * 定位完成
     */
    public final static int MSG_LOCATION_FINISH = 1;
    /**
     * 停止定位
     */

    /**
     * 根据定位结果返回定位信息的字符串
     *
     * @return
     */
    public synchronized static String getLocationStr(AMapLocation location, final int index) {
        if (null == location) {
            return null;
        }
        StringBuffer sb = new StringBuffer();
        //errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
        if (location.getErrorCode() == 0) {
            sb.append("定位成功" + "\n");
            sb.append("定位类型: " + location.getLocationType() + "\n");
            sb.append("
首页 上一页 2 3 4 5 下一页 尾页 5/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇svn基本常见操作设置 下一篇svn基本常见操作设置

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目