A polyline on the map is defined by the Polyline class and consists of a series of connected latitude/longitude points (LatLng objects).
Add a Polyline
Similar to markers, the properties of a Polyline are configured using the PolylineOptions class. The following example demonstrates how to add a polyline:
List<LatLng> latLngs = new ArrayList<LatLng>();
latLngs.add(new LatLng(1.3400,103.7000));
latLngs.add(new LatLng(1.2800,103.8500));
latLngs.add(new LatLng(1.3500,103.9800));
latLngs.add(new LatLng(1.4300,103.8000));
polyline =AMap.addPolyline(new PolylineOptions().
addAll(latLngs).width(10).color(Color.argb(255, 1, 1, 1)));
The code above creates a black polyline with a width of 10 pixels, as shown in the following image:

For more advanced features, such as drawing colored lines or geodesic curves, refer to the official map examples .
Common Polyline Methods
The following methods are available in the PolylineOptions class.
Name | Meaning | Rule Description |
setCustomTexture(BitmapDescriptor customTexture) | Sets the texture for the polyline. | It is recommended that the texture resource width and height be powers of 2. |
setCustomTextureIndex(List<Integer> customTextureIndexes) | Sets the index array for segmented textures. | Used in conjunction with setCustomTextureList. |
setCustomTextureList(List customTextureList) | Sets the list of textures for segmented drawing. | Used in conjunction with setCustomTextureIndex. |
setDottedLine(boolean isDottedLine) | Sets whether the polyline is drawn as a dotted line. | false: solid line; true: dotted line. |
setUseTexture(boolean useTexture) | Sets whether to use a texture map. | When enabled, the polyline is rendered with the specified texture. |
useGradient(boolean useGradient) | Sets whether to use a gradient color. | When enabled, the polyline color transitions between specified colors. |
visible(boolean isVisible) | Sets the visibility of the polyline. | true: visible; false: hidden. |
width(float width) | Sets the width of the polyline. | Unit: pixels. |
zIndex(float zIndex) | Sets the Z-index of the polyline. | Controls the drawing order; higher values are drawn on top. |