Exemplo n.º 1
0
  @Override
  public void setLocationListener(LocationListener listener) {
    mLocationListener = listener;
    if (mLocationProvider != null) {
      mLocationProvider.setLocationListener(mLocationListener);

      final Location lastLocation = mLocationProvider.getLastFix();
      if (lastLocation != null) {
        mLocationListener.onLocationChanged(lastLocation);
      }
    }
  }
Exemplo n.º 2
0
  private void enableUserLocation(boolean enable) {
    if (mLocationProvider == null) {
      mLocationProvider =
          new UserLocationProvider(
              new GpsLocationProvider(getActivity().getApplicationContext()), mMapView);
      mLocationProvider.setDrawAccuracyEnabled(true);
      if (mLocationListener != null) {
        mLocationProvider.setLocationListener(mLocationListener);
      }

      mMapView.addOverlay(mLocationProvider);
    }

    if (enable) {
      mLocationProvider.enableMyLocation();

      if (mUserLocationTrackingMode == TrackingMode.NONE) {
        mLocationProvider.disableFollowLocation();
      } else {
        mLocationProvider.enableFollowLocation();
      }
    } else {
      mLocationProvider.disableFollowLocation();
      mLocationProvider.disableMyLocation();
    }
  }
Exemplo n.º 3
0
  @Override
  public void zoomToFitMyLocation(List<Coord2D> coords) {
    if (mLocationProvider != null) {
      LatLng userLocation = mLocationProvider.getMyLocation();
      if (userLocation != null) {
        final List<Coord2D> updatedCoords = new ArrayList<Coord2D>(coords);
        updatedCoords.add(DroneHelper.ILatLngToCoord(userLocation));
        zoomToFit(updatedCoords);
        return;
      }
    }

    zoomToFit(coords);
  }
Exemplo n.º 4
0
  private void setAutoPanMode(AutoPanMode current, AutoPanMode update) {
    if (mPanMode.compareAndSet(current, update)) {
      switch (current) {
        case DRONE:
          mDrone.removeDroneListener(this);
          break;

        case USER:
          mUserLocationTrackingMode = TrackingMode.NONE;
          if (mLocationProvider != null) {
            mLocationProvider.disableFollowLocation();
          }
          break;

        case DISABLED:
        default:
          break;
      }

      switch (update) {
        case DRONE:
          mDrone.addDroneListener(this);
          break;

        case USER:
          mUserLocationTrackingMode = TrackingMode.FOLLOW;
          if (mLocationProvider != null) {
            mLocationProvider.enableFollowLocation();
          }
          break;

        case DISABLED:
        default:
          break;
      }
    }
  }
Exemplo n.º 5
0
 @Override
 public void goToMyLocation() {
   if (mLocationProvider != null) {
     mLocationProvider.goToMyPosition(true);
   }
 }