如何在Android Studio中添加Snap to Roads Google Map
您好我想问一下当我有google map API给出的路线时如何添加Snap to Road。 我从A点到B点有一堆Lat lang并绘制一条像Polylines这样的线,但我想要的是如何从给定的路径添加此代码snap到Road? 这是如何从点A到点B添加更多点,这是我要添加的内容, https://developers.google.com/maps/documentation/roads/snap
我的项目看起来像这样
- 通过Json和Gson获取overview_polyline(应使用https://maps.googleapis.com/maps/api/directions/json?origin=…&destination=place_id:…&mode=DRIVING&key= .. )
-
按function将其解码为List
public List
decodePoly(String encoded) { // encoded is overview_polyline.points; List poly = new ArrayList (); int index = 0, len = encoded.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encoded.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 = encoded.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.添加到地图:
PolylineOptions polylineOptions= new PolylineOptions(); polylineOptions.addAll(decodePoly(overview_polyline.points)); mGoogleMap.addPolyline(polylineOptions.width(5).color(Color.BLUE).geodesic(false));
- java.lang.NoSuchFieldError:IBM_JAVA,用于Eclipse中的简单hbase Java客户端
- setOnClickListener导致“RuntimeException:无法启动” – NullPointerException
- 无法构建android项目它显示错误
- Android Studio:com.android.ide.common.process.ProcessException:
- 缺少与所有者的运行时依赖关系,gradle for android
- Android Studio:使用intent PROVIDES仅传递多个值1 VALUE?
- 如何在Android Studio中编辑.jar文件
- 如何设置Android Mock GPS位置?
- Android Studio:意想不到的顶级例外:
- 模拟器:glClear:466 GL err 0x502
- 来自File Provider Uri的Android 7.0 Notification Sound无法播放