The problem I am running into is how go.Scattermapbox is displaying the lines. Instead of drawing a line connecting longitude 100 to -170 and crossing the 180 meridian, it draws the line all the way around the world (Please view the attached image). I believe this is due to my points straddling -180 degrees longitude. If I just add 360 to the 170, it is displayed correctly, however that just moves the problem to values that straddle 0 degrees longitude (prime meridian). Has anyone else encountered this? How do you fix this issue?
Yes, I had already come to that solution (by adding 360) and mentioned it in my post. I was not sure how to apply that solution generically. For instance, if I do it for every longitude < 0, then the same problem persists, except straddling 0 degrees longitude.
After some searching, I found that in order to determine which points needed to be mapped, I calculate relative distances between all the points and find the point that has the average distance > 180. Then if that point is negative, I add 360, if it is positive, I subtract 360.