コード例 #1
0
  /** 判断当前位置位于哪个校区 */
  private void judge_position() {
    if (mLocation.getLatitude() < 36.648152
        && mLocation.getLongitude() > 117.068195
        && mLocation.getLatitude() > 36.642666
        && mLocation.getLongitude() < 117.080217) {

      flag = 2; // 燕山校区
    } else if (mLocation.getLatitude() < 36.66187
        && mLocation.getLongitude() > 117.501132
        && mLocation.getLatitude() > 36.651857
        && mLocation.getLongitude() < 117.520319) {
      flag = 0; // 明水校区
    } else if (mLocation.getLatitude() < 36.674867
        && mLocation.getLongitude() > 117.370944
        && mLocation.getLatitude() > 36.665148
        && mLocation.getLongitude() < 117.380147) {
      flag = 1; // 圣井校区
    } else if (mLocation.getLatitude() < 36.631209
        && mLocation.getLongitude() > 117.019616
        && mLocation.getLatitude() > 36.619802
        && mLocation.getLongitude() < 117.026629) {
      flag = 3; // 舜耕校区
    }
    mMap.clear();
    this.flipper.setDisplayedChild(flag);
    mMap.animateCamera(
        CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[flag], zoom_current));
    startTextView.setText(null);
    endTextView.setText(null);
    isClickStart = true;
    isClickTarget = false;
    loadMap(flag + 2, true);
  }
コード例 #2
0
  /** 实现左右滑动切换校区 */
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    float zoom = 17;
    if (e1.getX() - e2.getX() > 100) {
      if (flag < position_schoolLatLngs.length - 1) {
        flag++;
      } else {
        flag = 0;
      }
      this.flipper.setInAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_left_in));
      this.flipper.setOutAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_left_out));
    } else if (e1.getX() - e2.getX() < -100) {
      if (flag > 0) {
        flag--;
      } else {
        flag = position_schoolLatLngs.length - 1;
      }
      this.flipper.setInAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_right_in));
      this.flipper.setOutAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_right_out));
    }
    mMap.clear();
    loadMap(flag + 2, true);
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[flag], zoom));
    this.flipper.setDisplayedChild(flag);

    return false;
  }
コード例 #3
0
 /** @param level value range 3~20 */
 public void setZoomLevel(float level) {
   if (aMap != null) {
     if (level < aMap.getMinZoomLevel()) {
       level = aMap.getMinZoomLevel();
     } else if (level > aMap.getMaxZoomLevel()) {
       level = aMap.getMaxZoomLevel();
     }
     aMap.moveCamera(CameraUpdateFactory.zoomTo(level));
   }
 }
コード例 #4
0
 public void setOverlayVisibleBounds(VisibleBoundsVO data) {
   if (mOverlays != null && mOverlays.size() > 0) {
     LatLngBounds.Builder builder = LatLngBounds.builder();
     for (int i = 0; i < mOverlays.size(); i++) {
       LatLng item = mOverlays.get(i);
       builder.include(item);
     }
     aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), data.getPadding()));
   }
 }
コード例 #5
0
 /** 单击下方ViewFlipper回到校区中心点 */
 @Override
 public boolean onSingleTapUp(MotionEvent e) {
   mMap.clear();
   startTextView.setText(null);
   endTextView.setText(null);
   mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[flag], 17));
   isClickStart = true;
   isClickTarget = false;
   loadMap(flag + 2, true);
   return true;
 }
コード例 #6
0
 /**
  * 移动镜头到当前的视角。
  *
  * @since V2.1.0
  */
 public void zoomToSpan() {
   if (startPoint != null) {
     if (mAMap == null) return;
     try {
       LatLngBounds bounds = getLatLngBounds();
       mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
     } catch (Throwable e) {
       e.printStackTrace();
     }
   }
 }
コード例 #7
0
 public void setMarkerVisibleBounds(VisibleBoundsVO data) {
   List<Marker> list = aMap.getMapScreenMarkers();
   if (list != null && list.size() > 0) {
     LatLngBounds.Builder builder = LatLngBounds.builder();
     for (int i = 0; i < list.size(); i++) {
       LatLng item = list.get(i).getPosition();
       builder.include(item);
     }
     aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), data.getPadding()));
   }
 }
コード例 #8
0
  /** 设置地图 */
  private void setUpMap() {
    mMap.setOnMarkerClickListener(this); // 设置点击marker事件监听器
    mMap.setInfoWindowAdapter(this);
    mMap.setOnInfoWindowClickListener(this); // 设置点击infoWindow事件监听器
    mMap.setOnMapLoadedListener(this); // 设置map载入成功事件监听器
    mMap.setOnCameraChangeListener(this);
    routeSearch = new RouteSearch(getActivity());
    routeSearch.setRouteSearchListener(this);
    setLocation();
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[0], 17.904732f));
    startTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_start);
    startTextView.setFocusable(false);
    endTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_goals);
    endTextView.setFocusable(false);
    routeSearchImagebtn = (ImageButton) schoolView.findViewById(R.id.imagebtn_roadsearch_search);
    routeSearchImagebtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            strStart = startTextView.getText().toString().trim();
            strEnd = endTextView.getText().toString().trim();
            if (strStart == null || strStart.length() == 0) {
              Toast.makeText(getActivity(), "请选择起点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (strEnd == null || strEnd.length() == 0) {
              Toast.makeText(getActivity(), "请选择终点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (startPoint != null && endPoint != null) {
              if (NetworkUtils.isConnect(getActivity())) {
                progDialog = ProgressDialog.show(getActivity(), null, "正在搜索", true, true);
                searchRoute();
              } else {
                Toast.makeText(getActivity(), "亲,请检查网络连接", Toast.LENGTH_SHORT).show();
              }

              // searchRouteResult(startPoint, endPoint);
            }
          }
        });
  }
コード例 #9
0
 public void overlook(float angle) {
   if (aMap != null) {
     aMap.moveCamera(CameraUpdateFactory.changeTilt(angle));
   }
 }
コード例 #10
0
 public void rotate(float angle) {
   if (aMap != null) {
     aMap.moveCamera(CameraUpdateFactory.changeBearing(angle));
   }
 }
コード例 #11
0
 public void zoomOut() {
   if (aMap != null) {
     aMap.moveCamera(CameraUpdateFactory.zoomOut());
   }
 }
コード例 #12
0
 public void setCenter(double longitude, double latitude) {
   if (aMap != null) {
     LatLng latLng = new LatLng(latitude, longitude);
     aMap.moveCamera(CameraUpdateFactory.changeLatLng(latLng));
   }
 }