I am drawing a plain color PolyLine on my map the following way, and it works great:
PolylineOptions polyLine = new PolylineOptions();
polyLine.width(5);
polyLine.color(Color.RED);
polyLine.geodesic(true);
for (int i = 0; i < speed.length; i++) {
polyLine.add(new LatLng(lat, lng));
}
map.addPolyline(polyLine);
Now I would want to draw a polyline with different colors between different points, depending on the speed between those two points.
There doesn't seem to be an easy way of doing it.
I am referring to this question : draw polylines with different colors on v2 maps , and I can add multiple PolylineOptions
one after another, but I don't think that will be an efficient approach, given I have more than 2000 points in a simple data set to draw.
Is there a better practice?
The ideal implementation would be how Nike+ app draws lines on maps:
Would greatly appreciate any help.
Thanks in advance!
I just find a way to do that with OptionsLines, in fact, two OptionsLines. I use this function with a gpx file, that's why there ly personnal object TRKPT.
Now you have a beautiful line with gradient from green to red.
You can render anything you wish to a
Bitmap
and useGroundOverlay
orTileOverlay
with it.