How Can I Draw Arc Polyline in Google Map ?
I already used this code to create curved Polyline.
Here is the method
Hy , you need to change your showCurvePolyline method with this method.
private void showCurvedPolyline (LatLng p1, LatLng p2, double k) {
//Calculate distance and heading between two points
double d = 0;
if (d == 0)
d= SphericalUtil.computeDistanceBetween(origin, dest);
double h = SphericalUtil.computeHeading(p1, p2);
// Calculate midpoint position
LatLng midPoint = SphericalUtil.computeOffset(p1, d / 2, h);
//Apply some mathematics to calculate position of the circle center
double x = (1-k*k)*d*0.5/(2*k);
double r = (1+k*k)*d*0.5/(2*k);
LatLng c = SphericalUtil.computeOffset(p, x, h + 90.0);
//Polyline options
PolylineOptions options = new PolylineOptions();
List pattern = Arrays.asList(new Dash(30), new Gap(20));
//Calculate heading between circle center and two points
double h1 = SphericalUtil.computeHeading(c, p1);
double h2 = SphericalUtil.computeHeading(c, p2);
// Calculate position of the curve center point
double sqrCurvature = DEFAULT_CURVE_ROUTE_CURVATURE * DEFAULT_CURVE_ROUTE_CURVATURE;
double extraParam = distance / (4 * DEFAULT_CURVE_ROUTE_CURVATURE);
double midPerpendicularLength = (1 - sqrCurvature) * extraParam;
double r = (1 + sqrCurvature) * extraParam;
LatLng midCurvePoint = SphericalUtil.computeOffset(midPoint, midPerpendicularLength, heading - 90.0);
// Calculate heading between circle center and two points
double headingToOrigin = SphericalUtil.computeHeading(midCurvePoint, origin);
double headingToDest = SphericalUtil.computeHeading(midCurvePoint, dest);
// Calculate positions of points on the curve
double step = (headingToDest - headingToOrigin) / DEFAULT_CURVE_POINTS;
List points = new ArrayList<>();
for (int i = 0; i < DEFAULT_CURVE_POINTS; ++i) {
points.add(SphericalUtil.computeOffset(midCurvePoint, r, headingToOrigin + i * step));
}
for (int i=0; i
then you can draw the arcPolyLine.It was provided in the File Provided by previous answer.