Im using react-map-gl
and turf
in this image you could see the arc moves from source to destination via south. how can i change the angle of the arc so it could move from north.
the arc is drawn using the last method which is discussed in this thread https://github.com/Turfjs/turf/issues/1218 .
Codesandbox - https://codesandbox.io/s/stackoverflow-fix-ymk4r?file=/src/index.js
I'm not sure if I have understood your need, but if you want to basically draw an arc between points you could also do something like this:
const p1 = turf.point([-122.3811441, 37.6213129]);
const p2 = turf.point([-118.4107187, 33.9415889]);
const bearingToCenter = turf.bearing(p1, p2) + 90;
const midPoint = turf.center(turf.featureCollection([p1, p2]));
const arcRadius = 1000;
const theCenter = turf.destination(midPoint, arcRadius, bearingToCenter);
const bearing1 = turf.bearing(p1, theCenter);
const bearing2 = turf.bearing(p2, theCenter);
const arc = turf.lineArc(theCenter, arcRadius, bearing1 +180, bearing2 +180);
Clearly, the code is not perfect, but it's just a quick draft to give you the gist.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.