samedi 30 novembre 2019

MapBox problem while drawing line between two points with positive / negative longitude in Laravel 5.8

I have an application where I want to draw an arc / line between two locations. Everything works fine but when I want to draw a line between two points ( 1 with positive longitude like China --- 2nd with negative longitude like USA ). It draws an additional line somewhere near or exactly on equator line. see image enter image description here

Help in this regard is requested please. I have pasted the coordinates as well from code.

    //Coords for some place in China
    $from_lng = 115.5781792430219; //16.763;
    $from_lat = 36.204409420941516; //41.138;
    $results['from_coord'] = array($from_lng, $from_lat);

    //Coords for some place in USA
    $to_lng = -122.42963325696385; //9.515;
    $to_lat = 39.804333950461285; //40.901;
    $results['to_coord'] = array($to_lng, $to_lat);


    //Calculating average to center map
    $results['posn'] = array(
      ($from_lng + $to_lng)/2,
      ($from_lat + $to_lat)/2
    );


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire