栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Android Studio中将快照添加到Roads Google Map

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Android Studio中将快照添加到Roads Google Map

  1. 获取Json和Gson的overview_polyline(应使用 https://maps.googleapis.com/maps/api/directions/json?origin=...&destination=place_id:...&mode=DRIVING&key=...)
  2. 将其解码为按功能列出
        public List<LatLng> deprePoly(String enpred) {    // enpred is overview_polyline.points;     List<LatLng> poly = new ArrayList<LatLng>();    int index = 0, len = enpred.length();    int lat = 0, lng = 0;    while (index < len) {        int b, shift = 0, result = 0;        do { b = enpred.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5;        } while (b >= 0x20);        int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));        lat += dlat;        shift = 0;        result = 0;        do { b = enpred.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5;        } while (b >= 0x20);        int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));        lng += dlng;        LatLng p = new LatLng((((double) lat / 1E5)),     (((double) lng / 1E5)));        poly.add(p);    }    return poly;    }

3.Add to map:

        PolylineOptions polylineOptions= new PolylineOptions();    polylineOptions.addAll(deprePoly(overview_polyline.points));    mGoogleMap.addPolyline(polylineOptions.width(5).color(Color.BLUE).geodesic(false));


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/498618.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号