@Override
  public void init() {
    // 设置是否显示比例尺控件
    mapView.showScaleControl(true);
    // 设置是否显示缩放控件
    mapView.showZoomControls(false);
    baiduMap = mapView.getMap();
    // 设置监听
    baiduMap.setOnMapClickListener(
        new OnMapClickListener() {
          @Override
          public boolean onMapPoiClick(MapPoi mapPoi) {
            return false;
          }

          @Override
          public void onMapClick(final LatLng latLng) {
            System.out.println(latLng.latitude + "--" + latLng.longitude);
            geoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(latLng));
            showWaiting(true);
            ok.setEnabled(false);
            markFirstLocation();
            markClickLocation(latLng);
          }
        });
    // 检索
    geoCoder = GeoCoder.newInstance();
    geoCoder.setOnGetGeoCodeResultListener(getGeoCoderResultListener);
    // 开始定位
    client = new LocationClient(getApplicationContext());
    client.setLocOption(getDefaultLocationClientOption());
    client.registerLocationListener(dbListener);
    client.start();
    // waiting的layout的初始化
    waitingAnimation =
        AnimationUtils.loadAnimation(SelectLocationActivity.this, R.anim.anim_waiting);
    waitingIcon.setAnimation(waitingAnimation);
    showWaiting(true);
    // 位置列表初始化
    adapter = new LocationAdapter();
    locationListView.setAdapter(adapter);
    locationListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            locationList.get(currentLocation).setSelected(false);
            locationList.get(position).setSelected(true);
            currentLocation = position;
            adapter.notifyDataSetChanged();
            // 重置标志
            markFirstLocation();
            markClickLocation(locationList.get(position).getLatLng());
          }
        });
    // 按钮
    back.setOnClickListener(clickListener);
    ok.setOnClickListener(clickListener);
    ok.setEnabled(false);
    Log.e("tag", "---------------------create---------------------------");
  }
Пример #2
0
  public void initView() {

    iv_list = (ImageView) findViewById(R.id.iv_list);
    iv_list.setOnClickListener(this);
    iv_loc = (ImageView) findViewById(R.id.iv_loc);
    iv_loc.setOnClickListener(this);
    tv_title_right = (TextView) findViewById(R.id.tv_title_button);
    tv_title_right.setText("3km" + " >");
    tv_title_right.setVisibility(View.VISIBLE);
    tv_title_right.setOnClickListener(this);

    // 油价,距离信息
    ll_summary = (LinearLayout) findViewById(R.id.ll_summary);
    ll_summary.setOnClickListener(this);
    tv_name = (TextView) findViewById(R.id.tv_name);
    tv_distance = (TextView) findViewById(R.id.tv_distance);
    tv_price_a = (TextView) findViewById(R.id.tv_price_a);
    tv_price_b = (TextView) findViewById(R.id.tv_price_b);

    // MapView
    mMapView = (MapView) findViewById(R.id.bmapView);
    mMapView.showScaleControl(false);
    mMapView.showZoomControls(false);
    mBaiduMap = mMapView.getMap();
    // MapView配置定位到当前位置
    mBaiduMap.setMyLocationConfigeration(
        new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true, null));
    mBaiduMap.setMyLocationEnabled(true);
    // 注册监听
    mLocationClient = new LocationClient(mContext);
    mLocationClient.registerLocationListener(mListener);

    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); // 高精度;
    // Battery_Saving:低精度.
    option.setCoorType("bd09ll"); // 返回国测局经纬度坐标系:gcj02 返回百度墨卡托坐标系 :bd09
    // 返回百度经纬度坐标系 :bd09ll
    option.setScanSpan(0); // 设置扫描间隔,单位毫秒,当<1000(1s)时,定时定位无效
    option.setIsNeedAddress(true); // 设置是否需要地址信息,默认为无地址
    option.setNeedDeviceDirect(true); // 在网络定位时,是否需要设备方向
    mLocationClient.setLocOption(option);
  }
  private void initViews() {
    orderInfo = getIntent().getParcelableExtra(AutoCon.ORDER_INFO);

    mainTech = (TextView) findViewById(R.id.main_tech);
    mMapView = (MapView) findViewById(R.id.bdmapView);
    distance = (TextView) findViewById(R.id.distance);
    indentImage = (ImageView) findViewById(R.id.indent_image);
    indentText = (TextView) findViewById(R.id.indent_text);
    workTime = (TextView) findViewById(R.id.work_time);
    orderType = (TextView) findViewById(R.id.order_type);
    orderOwner = (TextView) findViewById(R.id.create_order_people);
    shopsLocation = (TextView) findViewById(R.id.shops_location);
    shopsAlias = (TextView) findViewById(R.id.shops_name);
    workNotes = (TextView) findViewById(R.id.work_notes);

    baiduMap = mMapView.getMap(); // 管理具体的某一个MapView对象,缩放,旋转,平移
    MapStatusUpdate mapStatusUpdate =
        MapStatusUpdateFactory.zoomTo(BaiduMapUtil.defaultLevel); // 默认级别12
    baiduMap.setMapStatus(mapStatusUpdate); // 设置缩放级别

    BaiduMapUtil.hiddenBaiduLogo(mMapView); // 隐藏百度广告图标
    mMapView.showZoomControls(false);
    mMapView.showScaleControl(true); // 默认是true,显示标尺

    BaiduMapUtil.initData();
    setListener();

    if (orderInfo != null) {
      orderId = orderInfo.getId();
      mainTech.setText(orderInfo.getMainTech().getName());
      setData(orderInfo);
    } else {
      T.show(this, R.string.loading_data_failure);
      return;
    }
  }
Пример #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    requestWindowFeature(Window.FEATURE_NO_TITLE); // 去掉标题栏
    super.onCreate(savedInstanceState);

    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.navigate);
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.mapview_navi);
    mBaiduMap = mMapView.getMap();
    mMapView.showZoomControls(false);
    mMapView.showScaleControl(true);
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 开启罗盘
    mBaiduMap.getUiSettings().setCompassEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型为百度经纬度坐标
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();

    mBaiduMap.setOnMapLongClickListener(MyLongClickListener);

    // 初始化导航引擎
    //       BaiduNaviManager.getInstance().initEngine(this, getSdcardDir(),
    //       		mNaviEngineInitListener,ACCESS_KEY,mKeyVerifyListener);
    /*
            BaiduNaviManager.getInstance().initEngine(this, getSdcardDir(),
            mNaviEngineInitListener, new LBSAuthManagerListener() {
                @Override
                public void onAuthResult(int status, String msg) {
                    String str = null;
                    if (0 == status) {
                        str = "key校验成功!";
                    } else {
                        str = "key校验失败, " + msg;
                    }
                    Toast.makeText(NavigateActivity.this, str,
                            Toast.LENGTH_LONG).show();
                }
            });
    */
    boolean isInitSuccess =
        BaiduNaviManager.getInstance().checkEngineStatus(getApplicationContext());
    Toast.makeText(NavigateActivity.this, "isInitSuccess" + isInitSuccess, Toast.LENGTH_LONG)
        .show();

    // 设置策略
    TextView SetStrategy = (TextView) findViewById(R.id.tvStrategy);
    SetStrategy.setOnClickListener(
        new OnClickListener() {

          @SuppressWarnings("deprecation")
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            showDialog(0);
          }
        });

    // 规划路径
    TextView CalcRoute = (TextView) findViewById(R.id.tvCalcRoutes);
    CalcRoute.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (hasEndpoint = true) {
              drivintResultIndex = 0;
              nextLineBtn.setEnabled(false);
              drivingSearch(drivintResultIndex); // 驾车路线规划
              // startCalcRoute(NL_Net_Mode.NL_Net_Mode_OnLine);
            } else {
              Toast.makeText(NavigateActivity.this, "请先设置终点!", Toast.LENGTH_SHORT).show();
            }
          }
        });
    routePlanSearch = RoutePlanSearch.newInstance();
    routePlanSearch.setOnGetRoutePlanResultListener(routePlanResultListener);

    // 开始导航
    TextView StartNavigate = (TextView) findViewById(R.id.tvStartNavi);
    StartNavigate.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            //		launchNavigator();
            startNaviByClient(); // 调用客户端的方式发起导航
          }
        });

    // 下一条路径
    nextLineBtn = (Button) findViewById(R.id.nextline_btn);
    nextLineBtn.setEnabled(false);
    nextLineBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            drivingSearch(++drivintResultIndex);
          }
        });
  }