Example #1
0
  /**
   * computes a geopoint the is the central geopoint between the user and the car. also it zooms so
   * both marks are visible on the map
   *
   * @author ricky barrette
   */
  protected void showBoth() {
    if (mMap != null) {
      if (mCarPoint == null) {
        Toast.makeText(getActivity(), R.string.mark_car_first, Toast.LENGTH_LONG).show();
      } else if (mMap.getUserLocation() == null) {
        Toast.makeText(getActivity(), R.string.no_gps_signal, Toast.LENGTH_LONG).show();
      } else {
        if (mMap.getMap() != null) {
          mMap.getMap().getController().stopAnimation(false);
          mMap.followUser(false);
          final GeoPoint user = mMap.getUserLocation();

          /*
           * here we null check our next set of value before we send
           * them off to geoutils if they have became null for some
           * reason we disable show both mode
           */
          if (mCarPoint != null && user != null) {
            new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        mHandler.sendMessage(
                            mHandler.obtainMessage(MIDPOINT, GeoUtils.midPoint(mCarPoint, user)));
                      }
                    })
                .start();
          }

        } else {
          Log.e(TAG, "showBoth.mMap.getMap() is null");
        }
      }
    }
  }
Example #2
0
  /**
   * Trys to pan the map to the users location
   *
   * @author ricky barrette
   * @return true if successfull
   */
  private boolean myLocation() {
    mMap.followUser(true);

    /*
     * if we have a gps signal, then pan to user location else notify user
     * that there is no GPS signal
     *
     * we switch from MyLocationOverlay.getMyLocation() to referencing the
     * static variable MyCustomLocationOverlay.gpUser because for some
     * reason getMyLocation() would become null.
     *
     * @author ricky barrette
     */
    if (!panToGeoPoint(mMap.getUserLocation(), true)) {
      Toast.makeText(getActivity(), R.string.no_gps_signal, Toast.LENGTH_LONG).show();
      return false;
    } else return true;
  }
Example #3
0
  /**
   * Marks the user's location
   *
   * @author ricky barrette
   */
  private void markMyLocation() {
    mMap.followUser(true);

    /*
     * if we have a gps signal, then pan to user location and then if there
     * is no car, mark the car location as the users location else show mark
     * car dialog
     *
     * we switch from MyLocationOverlay.getMyLocation() to referencing the
     * static variable MyCustomLocationOverlay.gpUser because for some
     * reason getMyLocation() would become null.
     *
     * @author ricky barrette
     */
    if (myLocation())
      if (mCarPoint != null) markCarDialog();
      else markCar();
  }