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
 /**
  * removes the previous car overlay and replaces it with a new car overlay that represents the
  * users car at a specific geopoint
  *
  * @param point for geopoint of car
  * @author WWPowers 3-31-2010
  * @author ricky barrette
  */
 public void setCar(GeoPoint point) {
   isCarFound = false;
   hasLeftCar = false;
   mCarPoint = point;
   mCarOverlay = new FindMyCarOverlay(getActivity(), point);
   mMap.getMap().getOverlays().add(mCarOverlay);
   mMap.setDestination(mCarPoint);
 }
Example #3
0
 /**
  * pans maps to where the a geopoint is, and if zoomIn is true, zooms in to level 20
  *
  * @param GeoPoint point - lat and lon of point to pan to
  * @param boolean zoomIn - true if map needs to be zoomed in
  * @return boolean false it geopoint is null
  * @author ricky barrette
  */
 public boolean panToGeoPoint(GeoPoint point, boolean zoomIn) {
   if (point != null) {
     if (mMap != null) {
       try {
         mMap.getMap().getController().setCenter(point);
       } catch (Exception e) {
         e.printStackTrace();
       }
       if (zoomIn) {
         mMap.getMap().getController().setZoom((mMap.getMap().getMaxZoomLevel() - 2));
       }
     } else {
       Log.e(TAG, "panToGeoPoint call. mapcontroller was null");
     }
   } else {
     Log.e(TAG, "panToGeoPoint call. geopoint was null");
     return false;
   }
   return true;
 }
Example #4
0
  /**
   * removes the car overlay from the mapview.
   *
   * @return true if successful
   * @author ricky barrette
   */
  public boolean removeCar() {

    mCarPoint = null;
    mDistance.setText("0");
    mSettings.edit().remove(Settings.LAT).remove(Settings.LON).commit();
    mMap.setDestination(null);
    if (mListener != null) mListener.onCarDeleted();
    if (mDirections != null) {
      mDirections.removePath();
      mDirections = null;
    }

    try {
      mMap.getMap().getOverlays().remove(mCarOverlay);
    } catch (Exception e) {
      return false;
    }
    return true;
  }
Example #5
0
 /**
  * changes the map mode
  *
  * @author ricky barrette
  */
 private void changeMapMode() {
   if (mMap.getMap() != null) mMap.getMap().setSatellite(!mMap.getMap().isSatellite());
 }