public class Polyline extends BaseOverlay
它拥有以下属性:
线段是由两个顶点之间连贯的点构成的。如果两个顶点相同,则一个线段将闭合。
宽度是单位是像素。宽度是可视区域的缩放级别无关。默认为10。
线段的颜色是ARGB格式,颜色格式可以参考 Color。默认是黑色(0xff000000)。
Z轴是控制地图覆盖物(overlay)之间的绘制层次的参数。这个参数能够控制Circles、Polygons、Polyline的绘制层次,但不会影响marker。 Z轴数值越大的覆盖物(overlay)将会绘制在更上层。如果两个及两个以上覆盖物(overlay)的Z轴数值相同,则最后的绘制结果是随机的。 覆盖物(overlay)的Z轴默认为0。
这个属性表示了线段是否可以显示在地图上。如果设置为不可见,则绘制地图时不会绘制此线段,但其他属性不受影响。默认为可见。
It has the following attributes:
A polyline is formed by consecutive points between two vertices. If the two vertices are the same, the polyline will be closed.
The width is measured in pixels. The width is independent of the zoom level of the visible area. The default is 10.
The color of the polyline is in ARGB format, and the color format can refer to Color. The default is black (0xff000000).
The Z-axis is a parameter that controls the drawing hierarchy between map overlays. This parameter can control the drawing hierarchy of Circles, Polygons, and Polylines, but it does not affect markers. Overlays with a larger Z-axis value will be drawn on top. If two or more overlays have the same Z-axis value, the final drawing result is random. The default Z-axis value for overlays is 0.
This attribute indicates whether the polyline can be displayed on the map. If set to invisible, the polyline will not be drawn when the map is rendered, but other attributes are not affected. The default is visible.
Field1, Field2, overlayName| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
equals(java.lang.Object other) |
int |
getColor()
获取线段的颜色
Get the color of the polyline |
java.lang.String |
getId()
获取线段的Id。
|
LatLng |
getNearestLatLng(LatLng latLng)
获取某坐标点距线上最近的坐标点。
|
PolylineOptions |
getOptions()
获取线段选项信息
Get polyline options |
java.util.List<LatLng> |
getPoints()
获取线段的顶点坐标点列表。
|
float |
getWidth()
获取线段的宽度
Get the width of the polyline |
float |
getZIndex()
获取线段的z轴值。
|
int |
hashCode() |
boolean |
isDottedLine()
获取线段是否虚线。
|
boolean |
isGeodesic()
获取线段是否为大地曲线,默认false,不画大地曲线。
|
boolean |
isVisible()
获取线段是否可见
Get whether the polyline is visible |
void |
remove()
从地图上删除当前线段。
|
void |
setColor(int color)
设置线段的颜色
Set the color of the polyline |
void |
setCustomTexture(BitmapDescriptor customTexture)
设置线段的自定义纹理
Set custom texture for polyline |
void |
setDottedLine(boolean isDottedLine)
设置线段是否虚线,默认为false,画实线。
|
void |
setEraseColor(boolean eraseVisible,
int eraseColor)
设置线段擦除(显示范围外)颜色,需要传入32位的ARGB格式,针对颜色线段生效。
|
void |
setGeodesic(boolean isGeodesic)
设置线段是否画大地曲线,默认false,不画大地曲线。
|
void |
setOptions(PolylineOptions options)
设置线段选项信息
设置多个属性时可以使用此方法,单个属性设置建议使用各自对应的方法。 |
void |
setPoints(java.util.List<LatLng> points)
设置线段的坐标点列表。
|
void |
setTransparency(float transparency)
设置线段的透明度,需要使用纹理,此方法才有效,如果只设置颜色透明度,使用color即可
Set the transparency of the polyline, a texture is required for this method to be effective. |
void |
setVisible(boolean visible)
设置线段的可见属性。
|
void |
setWidth(float width)
设置线段的宽度
Set the width of the polyline |
void |
setZIndex(float zIndex)
设置线段的z轴值。
|
method1, method2public void remove()
public java.lang.String getId()
public void setPoints(java.util.List<LatLng> points)
points - 线段顶点的坐标列表
public java.util.List<LatLng> getPoints()
如果调用此方法获得顶点坐标后并且修改了顶点坐标,也不会作用到当前线程。如果需要修改线段的顶点值必须调用 Polyline.setPoints(List)。
If you call this method to obtain the vertex coordinates and modify the vertex coordinates, it will not affect the current thread. If you need to modify the vertex values of the polyline, you must call Polyline.setPoints(List).
public void setGeodesic(boolean isGeodesic)
isGeodesic - true:画大地曲线;false:不画大地曲线。
public boolean isGeodesic()
public void setDottedLine(boolean isDottedLine)
isDottedLine - true,画虚线;false,画实线。
public boolean isDottedLine()
public void setWidth(float width)
width - 线段宽度 单:像素
public float getWidth()
public void setColor(int color)
color - 颜色的ARGB格式
public int getColor()
public void setZIndex(float zIndex)
zIndex - z轴值。
public float getZIndex()
public void setVisible(boolean visible)
visible - true: 可见; false: 不可见。
public boolean isVisible()
public boolean equals(java.lang.Object other)
equals 在类中 java.lang.Objectpublic int hashCode()
hashCode 在类中 java.lang.Objectpublic LatLng getNearestLatLng(LatLng latLng)
latLng - - 一个经纬度点。
public void setTransparency(float transparency)
transparency - 透明度 范围0~1, 默认是1, 1表示不透明
public void setCustomTexture(BitmapDescriptor customTexture)
customTexture - 纹理图片 BitmapDescriptor
BitmapDescriptorpublic void setOptions(PolylineOptions options)
options - 线段选项信息 PolylineOptions
PolylineOptionspublic PolylineOptions getOptions()
PolylineOptions
PolylineOptionspublic void setEraseColor(boolean eraseVisible,
int eraseColor)
PolylineOptions.setShownRange(float rangeBegin, float rangeEnd)使用后生效
PolylineOptions.setShownRange(float rangeBegin, float rangeEnd) is used.eraseVisible - 擦除线段(线段显示范围外)可见性,默认不可见。
eraseColor - 擦除线段(线段显示范围外)颜色