How to draw a dynamic line (route) with Google Maps Android API v2

后端 未结 2 536
野趣味
野趣味 2021-02-10 01:07

I\'m wondering what the best practice is to draw a dynamic route on a map with the Google Maps API v2. I want to have a map that\'s able to prolong the route while the user is m

2条回答
  •  北海茫月
    2021-02-10 01:33

    Looking at the documentation, it appears that polylineOptions.add(LatLng) and googleMap.addPolyline(polylineOptions) methods return the polylineOptions object. The first method will also return polylineOptions WITH the point added to the end.

    I think you'll have to add the polylineOptions to googleMap.addPolyline(polylineOptions) again or use googleMap.clear() before adding it a second time. Somehting like this:

    polylineOptions = googleMap.addPolyline(polylineOptions);
    // googleMap.clear();
    googleMap.addPolyline(polylineOptions.add(point));
    

提交回复
热议问题