输入不可为空

导航

 

final LatLng ll = new LatLng(latiide, longitude);
                BitmapDescriptor descriptor = BitmapDescriptorFactory
                        .fromResource(marker);
                OverlayOptions options = new MarkerOptions().position(ll).icon(
                        descriptor);
                mBaiduMap.addOverlay(options);

 

路线规划:

      mMapView = (MapView) findViewById(R.id.bmapView);
        mBaiduMap = mMapView.getMap();
        search = RoutePlanSearch.newInstance();
        search.setOnGetRoutePlanResultListener(listener);

        //需要规划的两点
        PlanNode st = PlanNode.withLocation(new LatLng(39.931867, 116.395645));
        PlanNode ed = PlanNode.withLocation(new LatLng(39.915267, 116.40355));

         search.walkingSearch(new WalkingRoutePlanOption().from(st).to(ed));

当然好有他的事件:

OnGetRoutePlanResultListener listener = new OnGetRoutePlanResultListener() {
        public void onGetWalkingRouteResult(WalkingRouteResult result) {
            // 获取步行线路规划结果
            if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
                Toast.makeText(DaoHangActivity.this, "抱歉,未找到结果",
                        Toast.LENGTH_SHORT).show();
            }
            if (result.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
                // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
                // result.getSuggestAddrInfo()
                return;
            }
            if (result.error == SearchResult.ERRORNO.NO_ERROR) {

                // route = result.getRouteLines().get(0);
                WalkingRouteOverlay overlay = new MyWalkingRouteOverlay(
                        mBaiduMap);
                mBaiduMap.setOnMarkerClickListener(overlay);
                routeOverlay = overlay;
                overlay.setData(result.getRouteLines().get(0));
                overlay.addToMap();
                overlay.zoomToSpan();
            }

        }

        public void onGetTransitRouteResult(TransitRouteResult result) {
            // 获取公交换乘路径规划结果
        }

        public void onGetDrivingRouteResult(DrivingRouteResult result) {
            // 获取驾车线路规划结果
        }

    };
自定义起点终点 图标:

    private class MyWalkingRouteOverlay extends WalkingRouteOverlay {

        public MyWalkingRouteOverlay(BaiduMap baiduMap) {
            super(baiduMap);
        }

        @Override
        public BitmapDescriptor getStartMarker() {
            if (useDefaultIcon) {
                return BitmapDescriptorFactory.fromResource(R.drawable.icon_st);
            }
            return null;
        }

        @Override
        public BitmapDescriptor getTerminalMarker() {
            if (useDefaultIcon) {
                return BitmapDescriptorFactory.fromResource(R.drawable.icon_en);
            }
            return null;
        }
    }

 

posted on 2014-08-14 15:15  输入不可为空  阅读(1852)  评论(0编辑  收藏  举报