draw polylines with different colors on v2 maps

╄→гoц情女王★ 提交于 2019-12-23 18:36:30

问题


I am drawing multiple polylines using for loop on version 2 google map. I am setting color to the polyline using the code.

mMap.addPolyline(new PolylineOptions()
.add(new LatLng(lats, lons), new LatLng(late,lone))
.width(5)
.color(0xFFFF0000)); 

How to increment the RGB color dynamically for each for loop iteration.


回答1:


  Random rnd = new Random(); 
  int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));  
  --- loop ----

   mMap.addPolyline(new PolylineOptions()
  .add(new LatLng(lats, lons), new LatLng(late,lone))
  .width(5)
  .color(color)); 


来源:https://stackoverflow.com/questions/16214275/draw-polylines-with-different-colors-on-v2-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!