Пример #1
0
  /** init mapview */
  public void initMap() {

    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    // remove map logo
    mMapView.removeViewAt(1);

    int childCount = mMapView.getChildCount();
    View zoom = null;
    for (int i = 0; i < childCount; i++) {
      View child = mMapView.getChildAt(i);
      if (child instanceof ZoomControls) {
        zoom = child;
        break;
      }
    }
    zoom.setVisibility(View.GONE);

    mBaiduMap = mMapView.getMap();
    UiSettings mUiSettings = mBaiduMap.getUiSettings();
    mUiSettings.setCompassEnabled(false);

    mBaiduMap.setMyLocationEnabled(true);
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    option.setIsNeedAddress(true);
    mLocClient.setLocOption(option);
    mLocClient.start();
  }
Пример #2
0
 private void removeZoom() {
   int childCount = mMapView.getChildCount();
   View zoom = null;
   for (int i = 0; i < childCount; i++) {
     View child = mMapView.getChildAt(i);
     if (child instanceof ZoomControls) {
       zoom = child;
       break;
     }
     if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) {
       child.setVisibility(View.INVISIBLE);
     }
   }
   zoom.setVisibility(View.GONE);
 }
  private void initialLayout() {
    mLatitude = Double.parseDouble(preference.getString("latitude", "0.00"));
    mLongitude = Double.parseDouble(preference.getString("longitude", "0.00"));

    mapView = (MapView) findViewById(R.id.mapView);
    // 去掉百度Logo
    int count = mapView.getChildCount();
    for (int i = 0; i < count; i++) {
      View child = mapView.getChildAt(i);
      if (child instanceof ImageView) {
        child.setVisibility(View.INVISIBLE);
      }
    }

    baiduMap = mapView.getMap();
    // 初始化地图位置
    locLatLng = new LatLng(mLatitude, mLongitude);
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(locLatLng);
    baiduMap.animateMapStatus(u);

    // 设置地图放大级别 0-19
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17);
    baiduMap.animateMapStatus(msu);

    // 开启定位图层
    baiduMap.setMyLocationEnabled(true);
    // 自定义Maker
    BitmapDescriptor mCurrentMarker =
        BitmapDescriptorFactory.fromResource(R.drawable.icon_arrow_up);

    baiduMap.setOnMapClickListener(
        new OnMapClickListener() {

          @Override
          public boolean onMapPoiClick(MapPoi mapPoi) {
            clickLatLng = mapPoi.getPosition();
            addMakerToMap(clickLatLng);
            isClick = true;

            Toast.makeText(
                    getApplicationContext(),
                    "您选中了:" + mapPoi.getName().replace("\\", ""),
                    Toast.LENGTH_SHORT)
                .show();

            return false;
          }

          @Override
          public void onMapClick(LatLng latLng) {
            clickLatLng = latLng;
            addMakerToMap(clickLatLng);
            isClick = true;
          }
        });

    layoutConfirm = (RelativeLayout) findViewById(R.id.layoutConfirm);
    layoutConfirm.setOnClickListener(new MyOnClickListener());
    btnConfirm = (Button) findViewById(R.id.btnConfirm);
    btnConfirm.setOnClickListener(new MyOnClickListener());

    layoutBack = (RelativeLayout) findViewById(R.id.layoutBack);
    layoutBack.setOnClickListener(new MyOnClickListener());
    btnBack = (Button) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(new MyOnClickListener());

    textHint = (TextView) findViewById(R.id.textHint);
    imageHandClick = (ImageView) findViewById(R.id.imageHandClick);
  }