Search code examples
androidandroid-maps-v2

Adding multiple points in map using polyline and arraylist


How to draw a polyline in google map for multiple latitude and longitude coordinates. I need to draw polyline for atleast 20 sets of latitude and longitude dynamically.


Solution

  • Example from Android documentation:

       GoogleMap map;
       // ... get a map.
       // Add a thin red line from London to New York.
       Polyline line = map.addPolyline(new PolylineOptions()
         .add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
         .width(5)
         .color(Color.RED));
    

    Just call .add as many times as you need.