700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java百度地图路线规划 公交路线规划

java百度地图路线规划 公交路线规划

时间:2021-10-01 17:46:32

相关推荐

java百度地图路线规划 公交路线规划

/**

* 设置路线数据。

*

* @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;

}

复制

深色

复制成功

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。