public void OnGetDrivingRouteResult(MKDrivingRouteResult res, int error) { }
public void OnGetDrivingRouteResult(MKDrivingRouteResult res, int error) { //起点或终点有歧义,需要选择具体的城市列表或地址列表 if (error == MKEvent.ErrorRouteAddr) { //遍历所有地址 //IList<MKPoiInfo> stPois = res.AddrResult.MStartPoiList; //IList<MKPoiInfo> enPois = res.AddrResult.MEndPoiList; //IList<MKCityListInfo> stCities = res.AddrResult.MStartCityList; //IList<MKCityListInfo> enCities = res.AddrResult.MEndCityList; return; } // 错误号可参考MKEvent中的定义 if (error != 0 || res == null) { Toast.MakeText(routePlanDemo, "抱歉,未找到结果", ToastLength.Short).Show(); return; } routePlanDemo.searchType = 0; routePlanDemo.routeOverlay = new RouteOverlay(routePlanDemo, routePlanDemo.mMapView); // 此处仅展示一个方案作为示例 routePlanDemo.routeOverlay.SetData(res.GetPlan(0).GetRoute(0)); //清除其他图层 routePlanDemo.mMapView.Overlays.Clear(); //添加路线图层 routePlanDemo.mMapView.Overlays.Add(routePlanDemo.routeOverlay); //执行刷新使生效 routePlanDemo.mMapView.Refresh(); // 使用zoomToSpan()绽放地图,使路线能完全显示在地图上 routePlanDemo.mMapView.Controller.ZoomToSpan(routePlanDemo.routeOverlay.LatSpanE6, routePlanDemo.routeOverlay.LonSpanE6); //移动地图到起点 routePlanDemo.mMapView.Controller.AnimateTo(res.Start.Pt); //将路线数据保存给全局变量 routePlanDemo.route = res.GetPlan(0).GetRoute(0); //重置路线节点索引,节点浏览时使用 routePlanDemo.nodeIndex = -1; routePlanDemo.mBtnPre.Visibility = ViewStates.Visible; routePlanDemo.mBtnNext.Visibility = ViewStates.Visible; }