0

In angular application I have called the API and fetched the data something likethis:

{
"Drone": {
    "Droneid": 1001,
    "latlong": [
        {
            "lat": 12.989839,
            "lon": 80.198822
        },
        {
            "lat": 13.051832,
            "lon": 80.194480
        },
        {
            "lat": 13.038453,
            "lon": 80.227442
        },
        {
            "lat": 13.009018,
            "lon": 80.242550
        },
        {
            "lat": 12.976903,
            "lon": 80.237056
        },
        {
            "lat": 12.956829,
            "lon": 80.193107
        },
        {
            "lat": 12.980917,
            "lon": 80.150531
        },
        {
            "lat": 13.007680,
            "lon": 80.149158
        },
        {
            "lat": 13.043805,
            "lon": 80.154651
        }
    ]
}
}

And I have placed the latlong array from the above object in variable

var latlngs = this.drones.Drone.latlong;

Now I have to calculate the distance from index-0 to index-2(from the latlong array) and index-0 to index-3,index-0 to index-4 and so on(I have to calculate distance from index-0 to all starting from index-2) Can anyone help me regarding this.

Bhargavi gottam
  • 93
  • 1
  • 11
  • spherical or planar coordinates? that is, is it acceptable to approx the distance over a plane other than the spherical mapping around the earth? – Mario Vernari Aug 27 '20 at 09:44
  • I have placed the circle of 5km radius with index- 0 and marker with index-1 ,now I have to calculate the distance form index-0 to all the coordinates starting from index 2 .Can you help me regarding this. – Bhargavi gottam Aug 27 '20 at 09:47
  • Have a look at this http://www.movable-type.co.uk/scripts/latlong.html and this https://stackoverflow.com/questions/14560999/using-the-haversine-formula-in-javascript – Mario Vernari Aug 27 '20 at 09:59
  • I don't know how to write for Angular, but I think the problem is only about the formula. – Mario Vernari Aug 27 '20 at 10:00

0 Answers0