How to draw path as I move starting from my current location using Google Maps

后端 未结 3 1468
不思量自难忘°
不思量自难忘° 2020-12-12 14:20

I am trying to draw route as I move from my current location. I am facing a big problem in drawing route dynamically please help me to solve it. I am having marker at my cur

3条回答
  •  情歌与酒
    2020-12-12 14:41

    Its Very Simple to draw the polyline as it Moves

    Steps 1 : Create a polyline variable for references to update like below

    private Polyline polyline_path;
    

    Step 2 : On MapReady Callback do like below

    PolylineOptions routes = new PolylineOptions().width(5).color(Color.BLUE);
        polyline_path = mMap.addPolyline(routes);
    

    Step3 : On new Location you got call below method by sending points to this method

      private void UpdatePoints(LatLng newlatlng) {
        List points = polyline_path.getPoints();
        points.add(newlatlng);
        polyline_path.setPoints(points);
    }
    

提交回复
热议问题