Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of polyline in android google map v2

I have this code found from this link https://developers.google.com/maps/documentation/android/shapes#customizing_appearances

Polyline line = map.addPolyline(new PolylineOptions()
    .add(new LatLng(-37.81319, 144.96298), new LatLng(-31.95285, 115.85734))
    .width(25)
    .color(Color.BLUE)
    .geodesic(true));

My Problem is Color in Color.Blue returns an error saying The name Color does not exist in the current context.

like image 573
fulgen Avatar asked Feb 06 '14 02:02

fulgen


1 Answers

Just define a color in your colors resources file and do this:

PolylineOptions rectLine = new PolylineOptions().width(4).color(context.getResources().getColor(R.color.cyan));

Works great for me.

like image 121
Emil Adz Avatar answered Oct 09 '22 14:10

Emil Adz