How to use center and lineArc to draw a curved line from PointA and PointB ?
See original GitHub issueI’m using a Layer
and a Feature
from react-mapbox-gl to draw a line from point to point B` ( see screenshot 1)
My goal is to use line-arc and center from turf js in order to have a curved line between point A and point B
I managed to get a curved line, but it’s not starting at Point A and it’s not finishing at Point B… it is instead drawn in the middle of the map (see screenshot number 2)
Here is my code
const features = turf.featureCollection([
turf.point(this.state.startFlying), // [-122.3811441, 37.6213129]
turf.point(this.state.destinationFlying), // [-118.4107187, 33.9415889]
]);
const theCenter = turf.center(features);
const arcRadius = 5;
const bearing1 = 25;
const bearing2 = 47;
const arc = turf.lineArc(theCenter, arcRadius, bearing1, bearing2);
const mappedCurvedFlyingCurve = arc.geometry.coordinates;
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Formula or Algorithm to Draw curved lines between points
Ullrich I'm not wanting to use Bezier Curves because I need the line to "touch" the point and the Bezier Curve will just...
Read more >Draw a curve or circle shape - Microsoft Support
Draw a curve. On the Insert tab, click Shapes. Under Lines, click Curve. Click where you want the curve to start, drag to...
Read more >OST - 06.04.01 Drawing Arcs (Curved Linear Segments)
Using any Linear Condition , draw a line dissecting the circle ... By adjusting the end points and the center point, you can...
Read more >Draw a curved line with given radius, and two locations
I found a solution for my question. What I did was. Get the distance between the two points (current location and next location) ......
Read more >About Curved Objects | AutoCAD 2022
Arcs--You can create arcs by specifying any three points. · Circles--You can create circles by specifying the center and the radius. · Polyline ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is how I did it:
Example of the result:
@crevulus I believe the issue is, once again, projection/spherical distortion, i.e. working with euclidean (plane) distance and bearing instead of Rhumb functions. In your case the distances are so big, compared to @savy-91’s example, that the final result is way off.
Look at this example, I believe it works much better, although still not 100% accurate: