Stay organized with collections Save and categorize content based on your preferences.
A polyline is a list of points, where line segments are drawn between consecutive points. A polyline has the following properties:
Color
. The default value is black (0xff000000
).
ButtCap
, SquareCap
, RoundCap
(applicable for solid stroke pattern) and CustomCap
(applicable for any stroke pattern). Default for both start and end: ButtCap
.
JointType
for supported joint types. The default value is JointType.DEFAULT
.
null
) or a sequence of PatternItem
objects to be repeated along the line. Available PatternItem
types: Gap
(defined by gap length in pixels), Dash
(defined by line width and dash length in pixels) and Dot
(circular, centered on the line, diameter defined by line width in pixels).
GroundOverlay
s, TileOverlay
s, Circle
s, and Polygon
s but not Marker
s). An overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays with the same z-index is arbitrary. The default zIndex is 0.
true
, i.e., visible.
true
. You can change this value at any time. The default is false
. If this property is set to true
, your app will receive notifications to the GoogleMap.OnPolylineClickListener
registered through GoogleMap.setOnPolylineClickListener(GoogleMap.OnPolylineClickListener)
.
Object
associated with the polyline. For example, the Object
can contain data about what the polyline represents. This is easier than storing a separate Map<Polyline, Object>
. As another example, you can associate a String
ID corresponding to the ID from a data set. Google Maps SDK for Android neither reads nor writes this property..
StrokeStyle
on different segments of the polyline.
Methods in this class must be called on the Android UI thread. If not, an IllegalStateException
will be thrown at runtime.
GoogleMap map;
// ... get a map.
// Add a thin red line from London to New York.
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
.width(5)
.color(Color.RED));
Developer Guide
For more information, read the Shapes developer guide.
Public Method Summary boolean int getColor()
Gets the color of this polyline.
Cap getEndCap()
Gets the cap at the end vertex of this polyline.
String getId()
Gets this polyline's id.
int getJointType()
Gets the joint type used at all vertices of the polyline except the start and end vertices.
List<PatternItem> getPattern()
Gets the stroke pattern of this polyline.
List<LatLng> getPoints()
Returns a snapshot of the vertices of this polyline at this time .
List<StyleSpan> Cap getStartCap()
Gets the cap at the start vertex of this polyline.
Object getTag()
Gets the tag for the polyline.
float getWidth()
Gets the width of this polyline.
float getZIndex()
Gets the zIndex of this polyline.
int boolean boolean isGeodesic()
Gets whether each segment of the line is drawn as a geodesic or not.
boolean isVisible()
Gets the visibility of this polyline.
void remove()
Removes this polyline from the map.
void setClickable(boolean clickable)
Sets the clickability of the polyline.
void setColor(int color)
Sets the color of this polyline.
void setEndCap(
CapendCap)
Sets the cap at the end vertex of this polyline.
void setGeodesic(boolean geodesic)
Sets whether to draw each segment of the line as a geodesic or not.
void setJointType(int jointType)
Sets the joint type for all vertices of the polyline except the start and end vertices.
void void void void setStartCap(
CapstartCap)
Sets the cap at the start vertex of this polyline.
void void setVisible(boolean visible)
Sets the visibility of this polyline.
void setWidth(float width)
Sets the width of this polyline.
void setZIndex(float zIndex)
Sets the zIndex of this polyline.
Inherited Method Summary From class java.lang.Object Objectclone()
boolean voidfinalize()
final Class<?>getClass()
inthashCode()
final voidnotify()
final voidnotifyAll()
StringtoString()
final voidwait(long arg0, int arg1)
final voidwait(long arg0)
final voidwait()
Public Methods public boolean equals (Object other)Tests if this Polyline
is equal to another.
Gets the color of this polyline.
ReturnsGets the cap at the end vertex of this polyline.
ReturnsGets this polyline's id. The id will be unique amongst all Polylines on a map.
ReturnsGets the joint type used at all vertices of the polyline except the start and end vertices. See JointType
for possible values.
Gets the stroke pattern of this polyline.
Returnsnull
if default is used.Returns a snapshot of the vertices of this polyline at this time . The list returned is a copy of the list of vertices and so changes to the polyline's vertices will not be reflected by this list, nor will changes to this list be reflected by the polyline. To change the vertices of the polyline, call setPoints(List)
.
Gets the cap at the start vertex of this polyline.
public Object getTag ()Gets the tag for the polyline.
ReturnssetTag
; null
if no tag has been set.Gets the width of this polyline.
ReturnsGets the zIndex of this polyline.
ReturnsGets whether each segment of the line is drawn as a geodesic or not.
Returnstrue
if each segment is drawn as a geodesic; false
if each segment is drawn as a straight line on the Mercator projection.Gets the visibility of this polyline.
ReturnsRemoves this polyline from the map. After a polyline has been removed, the behavior of all its methods is undefined.
public void setClickable (boolean clickable) public void setColor (int color)Sets the color of this polyline.
Parameters color the color in ARGB format public void setEndCap (Cap endCap)Sets the cap at the end vertex of this polyline. The default end cap is ButtCap
.
null
. public void setGeodesic (boolean geodesic)
Sets whether to draw each segment of the line as a geodesic or not.
Parameters geodesic iftrue
, then each segment is drawn as a geodesic; if false
, each segment is drawn as a straight line on the Mercator projection. public void setJointType (int jointType)
Sets the joint type for all vertices of the polyline except the start and end vertices.
See JointType
for allowed values. The default value JointType.DEFAULT
will be used if joint type is undefined or is not one of the allowed values.
Sets the stroke pattern of the polyline. The default stroke pattern is solid, represented by null
.
Sets the points of this polyline. This method will take a copy of the points, so further mutations to points
will have no effect on this polyline.
LatLng
s that are the vertices of the polyline. Must not be null
. public void setSpans (List<StyleSpan> spans)
Sets spans of the polyline.
public void setStartCap (Cap startCap)Sets the cap at the start vertex of this polyline. The default start cap is ButtCap
.
null
. public void setTag (Object tag)
Sets the tag for the polyline.
You can use this property to associate an arbitrary Object
with this polyline. For example, the Object
can contain data about what the polyline represents. This is easier than storing a separate Map<Polyline, Object>
. As another example, you can associate a String
ID corresponding to the ID from a data set. Google Maps SDK for Android neither reads nor writes this property. It is your responsibility to call setTag(null)
to clear the tag when you no longer need it, to prevent memory leaks in your app.
null
, the tag is cleared. public void setVisible (boolean visible)
Sets the visibility of this polyline. When not visible, a polyline is not drawn, but it keeps all its other properties.
Parameters visible iftrue
, then the polyline is visible; if false
, it is not. public void setWidth (float width)
Sets the width of this polyline.
Parameters width the width in screen pixels public void setZIndex (float zIndex)Sets the zIndex of this polyline. Polylines with higher zIndices are drawn above those with lower indices.
Parameters zIndex the zIndex of this polyline.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["The `Polyline` class in the Android Maps SDK is used to represent lines drawn on a map, connecting a series of points."],["Polylines are customizable in terms of color, width, pattern, and shape, with control over start/end caps and joint types."],["Developers can control the visibility, clickability, and drawing order (z-index) of polylines on the map."],["Styling can be applied to individual segments of a polyline using `setSpans`, and arbitrary data can be associated with a polyline using `setTag`."],["All interactions with the `Polyline` object must occur on the Android UI thread."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4