I want to curve polyline between two points.
Android do that with the help of SphericalUtil Class .
But in iOS i don't know how to do that.
For Android , Here is a reference link: Draw ARC Polyline in Google Map
I want same for iOS.
I want to curve polyline between two points.
Android do that with the help of SphericalUtil Class .
But in iOS i don't know how to do that.
For Android , Here is a reference link: Draw ARC Polyline in Google Map
I want same for iOS.
Copyright © 2021 Jogjafile Inc.
Late to the party, but adding a solution for anyone else coming across this in the future:
First: use
UIBezierPath
to draw your curvesFocus on the extension to
UIBezierPath
. Each pair of points is drawn as a quad curve using a perpendicular control point calculated inCGPoint.controlpoint(_, _)
.Play around with the
tension
value to alter the sharpness of the curve. Atension
of2
generates something close to a quarter-circle.Obviously this only deals in
CGPoints
, notCLLocationCoordinate2D
or any other map-related data. Fine for drawing in views, though:Next: Define a custom
MKOverlayPathRenderer
Finally: add a delegate to your map to use the custom renderer
Putting it all together, it looks like this:
If you're not a fan of the rabbit hop path:
... there are alternative methods to calculate control points for your bezier curves:
The method above scans ahead and behind the current point to derive two control points, resulting in a smoother path: