Search code examples
androidgpsandroid-maps-v2google-geocodergoogle-polyline

How to draw Polyline based on current location dynamically in Android


Hi i am developing a application where i tracks users current location periodically and update the path in Google map by drawing polylines . I am Not sure how to do that. Please Help me Out in this issue.


Solution

  • After drawing the Polyline for the first time, you can "update" that polyline by retrieving the actual points (getPoints()) and then adding the new location to that list, then updating PolylinePoints (setPoints()) https://developer.android.com/reference/com/google/android/gms/maps/model/Polyline.html#getPoints()

    Keep in mind that getPoints gives you a COPY of the points, not the reference to the list.