java.lang.Object | |
↳ | com.google.android.gms.maps.model.Polyline |
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 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
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 Android API neither reads nor writes this
property.
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));
For more information, read the Shapes developer guide.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the color of this polyline.
| |||||||||||
Gets the cap at the end vertex of this polyline.
| |||||||||||
Gets this polyline's id.
| |||||||||||
Gets the joint type used at all vertices of the polyline except the start and end vertices.
| |||||||||||
Gets the stroke pattern of this polyline.
| |||||||||||
Returns a snapshot of the vertices of this polyline at this time .
| |||||||||||
Gets the cap at the start vertex of this polyline.
| |||||||||||
Gets the tag for the polyline.
| |||||||||||
Gets the width of this polyline.
| |||||||||||
Gets the zIndex of this polyline.
| |||||||||||
Gets the clickability of the polyline.
| |||||||||||
Gets whether each segment of the line is drawn as a geodesic or not.
| |||||||||||
Gets the visibility of this polyline.
| |||||||||||
Removes this polyline from the map.
| |||||||||||
Sets the clickability of the polyline.
| |||||||||||
Sets the color of this polyline.
| |||||||||||
Sets the cap at the end vertex of this polyline.
| |||||||||||
Sets whether to draw each segment of the line as a geodesic or not.
| |||||||||||
Sets the joint type for all vertices of the polyline except the start and end vertices.
| |||||||||||
Sets the stroke pattern of the polyline.
| |||||||||||
Sets the points of this polyline.
| |||||||||||
Sets the cap at the start vertex of this polyline.
| |||||||||||
Sets the tag for the polyline.
| |||||||||||
Sets the visibility of this polyline.
| |||||||||||
Sets the width of this polyline.
| |||||||||||
Sets the zIndex of this polyline.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Parameters | |
---|---|
delegate |
IPolylineDelegate
|
Parameters | |
---|---|
other |
Object
|
Returns | |
---|---|
boolean |
Gets the color of this polyline.
Returns | |
---|---|
int |
the color in ARGB format. |
Gets the cap at the end vertex of this polyline.
Returns | |
---|---|
Cap |
the end cap type. |
Gets this polyline's id. The id will be unique amongst all Polylines on a map.
Returns | |
---|---|
String |
this polyline's id. |
Gets the joint type used at all vertices of the polyline except the start and end vertices.
See JointType
for possible values.
Returns | |
---|---|
int |
the joint type. |
Gets the stroke pattern of this polyline.
Returns | |
---|---|
List<PatternItem> |
the stroke pattern. |
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)
.
Returns | |
---|---|
List<LatLng> |
Gets the cap at the start vertex of this polyline.
Returns | |
---|---|
Cap |
the start cap. |
Gets the tag for the polyline.
Returns | |
---|---|
Object |
the tag if a tag was set with setTag ; null if no tag has been set.
|
Gets the width of this polyline.
Returns | |
---|---|
float |
the width in screen pixels. |
Gets the zIndex of this polyline.
Returns | |
---|---|
float |
the zIndex of the polyline. |
Returns | |
---|---|
int |
Gets the clickability of the polyline. If the polyline is clickable, your app
will receive notifications to the GoogleMap.OnPolylineClickListener
when the
user clicks the polyline. The event listener is registered through
setOnPolylineClickListener(GoogleMap.OnPolylineClickListener)
.
Returns | |
---|---|
boolean |
true if the polyline is clickable; otherwise, returns false .
|
Gets whether each segment of the line is drawn as a geodesic or not.
Returns | |
---|---|
boolean |
true 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.
Returns | |
---|---|
boolean |
this polyline's visibility. |
Removes this polyline from the map. After a polyline has been removed, the behavior of all its methods is undefined.
Sets the clickability of the polyline. If the polyline is clickable, your app will receive
notifications to the GoogleMap.OnPolylineClickListener
when the user clicks the
polyline. The event listener is registered through
setOnPolylineClickListener(GoogleMap.OnPolylineClickListener)
.
Parameters | |
---|---|
clickable |
boolean :
New clickability setting for the polyline.
|
Sets the color of this polyline.
Parameters | |
---|---|
color |
int :
the color in ARGB format
|
Sets the cap at the end vertex of this polyline. The default end cap is ButtCap
.
Parameters | |
---|---|
endCap |
Cap :
the end cap. Must not be null .
|
Sets whether to draw each segment of the line as a geodesic or not.
Parameters | |
---|---|
geodesic |
boolean :
if true , then each segment is drawn as a geodesic; if false ,
each segment is drawn as a straight line on the Mercator projection.
|
Sets the stroke pattern of the polyline. The default stroke pattern is solid, represented by
null
.
Parameters | |
---|---|
pattern |
List :
the stroke pattern.
|
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.
Parameters | |
---|---|
points |
List :
an list of LatLng s that are the vertices of the polyline.
|
Sets the cap at the start vertex of this polyline. The default start cap is ButtCap
.
Parameters | |
---|---|
startCap |
Cap :
the start cap. Must not be null .
|
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 Android
API 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.
Parameters | |
---|---|
tag |
Object :
if null, the tag is cleared.
|
Sets the visibility of this polyline. When not visible, a polyline is not drawn, but it keeps all its other properties.
Parameters | |
---|---|
visible |
boolean :
if true , then the polyline is visible; if false , it is not.
|
Sets the width of this polyline.
Parameters | |
---|---|
width |
float :
the width in screen pixels
|
Sets the zIndex of this polyline. Polylines with higher zIndices are drawn above those with lower indices.
Parameters | |
---|---|
zIndex |
float :
the zIndex of this polyline.
|