in MapBox iOS sdk 4.4.1 if the MGLPolyline crosses the (180 or -180) Longitude , the map shows that it is going the longer way around the globe instead of going the shorter way.
override func viewDidAppear(_ animated: Bool) {
let points = [
CLLocationCoordinate2D(latitude: 50.0, longitude: -170.0),
CLLocationCoordinate2D(latitude: 50.0, longitude: 170),
]
let line = MGLPolyline(coordinates: points, count: UInt(points.count))
line.title = "line"
mapView.addAnnotation(line)
}
It makes sense that consecutive points are joined along lines of increasing latitude and/or longitude but default. Mapbox’s info regarding how to overcome this for MGLPolyline is found here.
The part of interest is: Mapbox MGLPolyline link
To make the polyline go across the antimeridian or international date line, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, a polyline that stretches from Tokyo to San Francisco would have coordinates of (35.68476, -220.24257) and (37.78428, -122.41310).
So they're leaving it to the developer to implement their own logic to decide when and if it is appropriate to go the longer or shorter route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With