【发布时间】:2018-11-23 12:21:53
【问题描述】:
我想在移动时删除之前的折线,我正在使用 GoogleDirection 类来绘制折线。请参考下面的代码sn-p
GoogleDirection.withServerKey(getResources().getString(R.string.google_maps_key))
.from(origin)
.to(destination)
.transportMode(TransportMode.DRIVING)
.alternativeRoute(true)
.execute(this);
@Override
public void onDirectionSuccess(Direction direction, String rawBody) {
mMap.clear();
mMap.addMarker(new MarkerOptions().position(destination));
ArrayList<LatLng> directionPositionList = direction.getRouteList().get(0).getLegList().get(0).getDirectionPoint();
polyline = mMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 3, Color.BLACK));
}
@Override
public void onDirectionFailure(Throwable t) {
Log.e("Direction fail Sorry", " no route found for this location.");
请参考截图,需要根据当前位置更新折线。
【问题讨论】:
-
您找到解决方案了吗?
标签: android google-maps