Is there a way to get through the API (Yandex.Maps, Google Maps) an array of coordinates between two given points? Or maybe there are calculation methods? Coordinates are needed lying on a line between two points, there is no need to calculate the passage.
2 answers
Well, all the coordinates can not be obtained (they are just an infinite number), but to go through an arc of a large circle with some step - you can
Here, for example, interpolate from google.maps.geometry.encoding namespace
interpolate(from, to, fraction) Parameters: from: LatLng to: LatLng fraction: number Under the hood is probably used SLERP . If you need to independently implement - Intermediate point here
Can be calculated
Formula: a = sin((1−f)⋅δ) / sin δ b = sin(f⋅δ) / sin δ x = a ⋅ cos φ1 ⋅ cos λ1 + b ⋅ cos φ2 ⋅ cos λ2 y = a ⋅ cos φ1 ⋅ sin λ1 + b ⋅ cos φ2 ⋅ sin λ2 z = a ⋅ sin φ1 + b ⋅ sin φ2 φi = atan2(z, √x² + y²) λi = atan2(y, x) where f is fraction along great circle route (f=0 is point 1, f=1 is point 2), δ is the angular distance d/R between the two points. - @Madushko If you are given an exhaustive answer, mark it as correct (click on the checkbox next to the selected answer) - MBo
|
I join the answer above, also an example of a simple implementation can be found here https://tech.yandex.ru/maps/jsbox/2.1/polyline_animation in the generateSmoothCoords function
|