相关疑难解决方法(0)

谷歌地图Android API v2,如何从地图中删除折线?

我想删除以前添加的折线并在更改位置时重新绘制新的折线.我试过了两个

this.routeToDestination.setPoints(pointsToDestination)和this.routeToDestination.remove()

但他们都没有工作.

我按照如何用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);
    }

}
Run Code Online (Sandbox Code Playgroud)

android google-maps-android-api-2

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

google-maps-android-api-2 ×1