private MarkerCoordinateAnimatorListener(
     MyLocationBehavior myLocationBehavior, LatLng from, LatLng to) {
   behavior = myLocationBehavior;
   fromLat = from.getLatitude();
   fromLng = from.getLongitude();
   toLat = to.getLatitude();
   toLng = to.getLongitude();
 }
Example #2
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);
 }
  /**
   * 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;
  }