Android集成使用百度地图的时候,进行两地点之间路线的查询(地点信息可以在百度地图中搜索到),但是点击查询路线会出现起终点或途径点有歧义的问题,要如何解决,
时间: 2024-03-01 11:51:53 浏览: 11
在使用百度地图进行两地点之间路线查询时,若出现起终点或途径点有歧义的问题,可以通过以下方式进行解决:
1.在进行路线查询前,先使用百度地图提供的POI检索功能,查询目标地点的经纬度或地点名称,并将其作为路线查询的终点或途径点。
2.在进行路线查询时,可以通过调用以下API设置起点和终点的经纬度坐标,避免出现起终点歧义的问题:
```
//设置起点和终点的经纬度坐标
PlanNode startNode = PlanNode.withLocation(startLatLng);
PlanNode endNode = PlanNode.withLocation(endLatLng);
//设置驾车路线查询参数
DrivingRoutePlanOption option = new DrivingRoutePlanOption()
.from(startNode)
.to(endNode);
//发起驾车路线查询
mSearch.drivingSearch(option);
```
3.在进行路线查询时,还可以通过调用以下API设置途径点,避免出现途径点歧义的问题:
```
//设置途径点
List<PlanNode> wayPoints = new ArrayList<PlanNode>();
wayPoints.add(PlanNode.withLocation(wayPoint1));
wayPoints.add(PlanNode.withLocation(wayPoint2));
//设置驾车路线查询参数
DrivingRoutePlanOption option = new DrivingRoutePlanOption()
.from(startNode)
.to(endNode)
.waypoints(wayPoints);
//发起驾车路线查询
mSearch.drivingSearch(option);
```
通过以上方法,可以避免起终点或途径点歧义的问题,确保路线查询的准确性。