private MarkerCoordinateAnimatorListener(
     MyLocationBehavior myLocationBehavior, LatLng from, LatLng to) {
   behavior = myLocationBehavior;
   fromLat = from.getLatitude();
   fromLng = from.getLongitude();
   toLat = to.getLatitude();
   toLng = to.getLongitude();
 }
Exemplo n.º 2
0
 /**
  * Return a new LatLng object with a wrapped Longitude. This allows original data object to remain
  * unchanged.
  *
  * @return New LatLng object with wrapped Longitude
  */
 public LatLng wrap() {
   LatLng wrappedVersion = new LatLng(this);
   double lon = wrappedVersion.getLongitude();
   if (lon < GeoConstants.MIN_LONGITUDE || lon > GeoConstants.MAX_LONGITUDE) {
     wrappedVersion.setLongitude(
         MathUtils.wrap(
             wrappedVersion.getLongitude(),
             GeoConstants.MIN_LONGITUDE,
             GeoConstants.MAX_LONGITUDE));
   }
   return wrappedVersion;
 }
Exemplo n.º 3
0
 @Override
 public void onClick(View v) {
   for (Marker marker1 : markerList) {
     Timber.e("marker " + marker1.getDescription() + " " + marker1.getTitle());
     LatLng lg = marker1.getPoint();
     POI poi =
         new POI(
             marker1.getTitle(),
             marker1.getDescription(),
             lg.getLatitude(),
             lg.getLatitude());
     waypoints.add(poi);
   }
   Intent i = new Intent(getActivity(), TrajetActivity.class);
   Bundle bundle = new Bundle();
   bundle.putSerializable("waypoints", (Serializable) waypoints);
   i.putExtras(bundle);
   startActivity(i);
 }
Exemplo n.º 4
0
  /**
   * Calculate distance between two points
   *
   * @param other Other LatLng to compare to
   * @return distance in meters
   */
  public double distanceTo(LatLng other) {
    if (latitude == other.latitude && longitude == other.longitude) {
      // return 0.0 to avoid a NaN
      return 0.0;
    }

    final double a1 = Math.toRadians(this.latitude);
    final double a2 = Math.toRadians(this.longitude);
    final double b1 = Math.toRadians(other.getLatitude());
    final double b2 = Math.toRadians(other.getLongitude());

    final double cosa1 = Math.cos(a1);
    final double cosb1 = Math.cos(b1);

    final double t1 = cosa1 * Math.cos(a2) * cosb1 * Math.cos(b2);
    final double t2 = cosa1 * Math.sin(a2) * cosb1 * Math.sin(b2);
    final double t3 = Math.sin(a1) * Math.sin(b1);
    final double tt = Math.acos(t1 + t2 + t3);

    return GeoConstants.RADIUS_EARTH_METERS * tt;
  }