简体   繁体   中英

Android Google Map with Multiple Poly-line with different colors

I want to display multiple routes at the same time in google map in such a way that each route should be separate(eg Route1 ABC in Green Color and Route2 DEFG in Blue Color.... could be number of routes(Limited)) and for that I was trying to implement multiple poly-line with different color. I have faced some issues...

  1. Routes are not separated.
  2. Displaying in color which I am giving for the last route.

Image for requirement with 2 poly-line... but there could be n number of poly-line

You can achieve the same like this:

GoogleMap map;
   // ... get a map.

map.addPolyline(new PolylineOptions()
     .add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
     .width(5)
     .color(Color.RED));
map.addPolyline(new PolylineOptions()
     .add(new LatLng(75.5, -1.1), new LatLng(60.7, -84.0))
     .width(5)
     .color(Color.BLUE));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM