/**
* 设置路线数据。
*
* @param line 路线数据
*/
public void setData(TransitRouteLine line) {
mRouteLine = line;
}
@Override
public final List getOverlayOptions() {
if (mRouteLine == null) {
return null;
}
List overlayOptionses = new ArrayList();
// step node
if (mRouteLine.getAllStep()!= null
&& mRouteLine.getAllStep().size() > 0) {
for (TransitRouteLine.TransitStep step: mRouteLine.getAllStep()) {
Bundle b = new Bundle();
b.putInt("index", mRouteLine.getAllStep().indexOf(step));
if (step.getEntrance()!= null) {
overlayOptionses
.add((new MarkerOptions()).position(step.getEntrance().getLocation())
.anchor(0.5f, 0.5f).zIndex(10).extraInfo(b)
.icon(getIconForStep(step)));
}
// 最后路段绘制出口点
if (mRouteLine.getAllStep().indexOf(step) == (mRouteLine
.getAllStep().size() - 1)
&& step.getExit()!= null) {
overlayOptionses
.add((new MarkerOptions()).position(step.getExit().getLocation())
.anchor(0.5f, 0.5f).zIndex(10).icon(getIconForStep(step)));
}
}
}
if (mRouteLine.getStarting()!= null) {
overlayOptionses
.add((new MarkerOptions()).position(mRouteLine.getStarting().getLocation())
.icon(getStartMarker()!= null? getStartMarker()
: BitmapDescriptorFactory.fromAssetWithDpi("Icon_start.png"))
.zIndex(10));
}
if (mRouteLine.getTerminal()!= null) {
overlayOptionses
.add((new MarkerOptions())
.position(mRouteLine.getTerminal().getLocation())
.icon(getTerminalMarker()!= null? getTerminalMarker():
BitmapDescriptorFactory
.fromAssetWithDpi("Icon_end.png"))
.zIndex(10));
}
// polyline
if (mRouteLine.getAllStep()!= null
&& mRouteLine.getAllStep().size() > 0) {
ArrayList textureIndexs = new ArrayList();
List points = new ArrayList();
for (TransitRouteLine.TransitStep step: mRouteLine.getAllStep()) {
if (step.getWayPoints() == null) {
continue;
}
for (int i = 0; i < step.getWayPoints().size(); ++i) {
if (step.getStepType()
!= TransitRouteLine.TransitStep.TransitRouteStepType.WAKLING) {
textureIndexs.add(0);
} else {
textureIndexs.add(1);
}
}
points.addAll(step.getWayPoints());
}
overlayOptionses.add(new PolylineOptions().points(points).width(15).dottedLine(true)
.customTextureList(getCustomTextureList()).textureIndex(textureIndexs)
.zIndex(0));
}
return overlayOtionses;
}
public List getCustomTextureList() {
ArrayList list = new ArrayList();
list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png"));
return list;
}
复制
深色
复制成功