我如何像这个样例那样对折线进行动画处理?

时间:2018-08-19 23:48:54

标签: java android google-maps google-polyline

如何像下面的示例那样为折线设置动画。我通过以下方式加载折线,并从JSON文件中获取点。

但是我不能制作动画。在Google中寻找示例,但无法在我的代码中使用。

enter image description here

这是班级的定义

private List<Polyline> polylinePaths = new ArrayList<>();

这是我添加折线的片段代码

polylinePaths = new ArrayList<>();
originMarkers = new ArrayList<>();
waypoints = new ArrayList<>();
destinationMarkers = new ArrayList<>();



for (Route route : routes) {

    PolylineOptions polylineOptions = new PolylineOptions().
            geodesic(true).
           // color(R.color.geos).
            color(ContextCompat.getColor(getApplicationContext(),R.color.geos)).
            startCap(new SquareCap()).
            endCap(new SquareCap()).
            jointType(JointType.ROUND).
            width(10);

    for (int i = 0; i < route.points.size(); i++)
        polylineOptions.add(route.points.get(i));

    //polylinePaths.add(mMap.addPolyline(polylineOptions));


    if (estado.equals("inicioR") ) {


       // ((TextView) findViewById(R.id.tvDuration)).setText(estado + " Min");
        polylinePaths.add(mMap.addPolyline(polylineOptions));
        ((TextView) findViewById(R.id.tvDuration)).setText(route.duration + " Min");
        ((TextView) findViewById(R.id.tvDistance)).setText(route.distance + "");
    }else if (estado.equals("finR")){
      //  isRunning = false;
        //ha.removeCallbacksAndMessages(null);
        if (polylinePaths != null && !polylinePaths.isEmpty()) {
            polylinePaths.get(polylinePaths.size()-1).remove(); // remove the lastest line you added.
            polylinePaths.remove(polylinePaths.size()-1); // remove the lastest line record from ArrayList.

        }

0 个答案:

没有答案