【发布时间】:2013-02-28 15:24:59
【问题描述】:
我正在尝试删除以前添加的折线并在位置更改后重新绘制新的折线。我都试过了
this.routeToDestination.setPoints(pointsToDestination) 和 this.routeToDestination.remove()
但他们都没有工作。
我关注了How to draw a dynamic line (route) with Google Maps Android API v2,但无法解决问题
@Override
public void onResume() {
super.onResume();
routeToDestination = mMap.addPolyline(new PolylineOptions()
.add(new LatLng(location.getLatitude(), location.getLongitude()),
new LatLng(this.destinationLatitude, this.destinationLongitude))
.width(1)
.color(Color.DKGRAY)
);
}
@Override
public void onLocationChanged(Location location) {
List<LatLng> pointsToDestination = new ArrayList<LatLng>();
pointsToDestination.add(new LatLng(location.getLatitude(), location.getLongitude()));
pointsToDestination.add(new LatLng(destinationLatitude, destinationLongitude));
this.routeToDestination.setPoints(pointsToDestination);
}
}
【问题讨论】:
-
根据文档,
remove()应该可以工作。确保您在 SDK 管理器的 Extras 区域中使用最新版本的“Google Play 服务”库(现在最新的是“rev 5”)并且您正在使用该库项目。如果问题仍然存在,请创建一个示例项目来展示错误并将其发布,可能作为地图问题跟踪器的问题:code.google.com/p/gmaps-api-issues/issues/list -
谢谢,我去试试
-
我是否必须单独对地图应用更改(调用函数)?
-
据我所知没有。
-
更新“Google Play 服务”库解决了这个问题,谢谢
标签: android google-maps-android-api-2