MKOverlay无法正确接近180度子午线(快速)

时间:2017-10-03 15:03:57

标签: swift mapkit

我希望在<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency> MKOverlay上显示一对MapKit。他们渲染得很好。这就是他们的样子。

Properly rendered MKOverlays

一旦我开始接近第180个子午线,事情变得奇怪。出于某种原因,mapViewMKCircle都消失了。如果我进一步平移,则仅显示MKGeodesicPolyline

Only MKGeodesicPolyline properly rendered

我确保纬度都不超过180和-180。这是一个代码片段:

MKGeodesicPolyline

我做了一些搜索,我发现,//I know the math here could be a little bit better but this was just a temporary fix if newCoordinates.longitude > 180 { newCoordinates.longitude = -(180 + (180 - newCoordinates.longitude)) }else if newCoordinates.longitude < -180 { newCoordinates.longitude = 180 + (180 + newCoordinates.longitude) } if newCoordinates.latitude > 90 { newCoordinates.latitude = 90 }else if newCoordinates.latitude < -90 { newCoordinates.latitude = -90 } 可能无法显示通过第180个子午线的折线,但这可以通过绘制两条折线来解决(1.开始-180&amp; 2. 180到END)。但那只会解决我问题的一半。 MapKit由于某种原因也会消失,即使坐标是正确的。我能做些什么呢?希望你能帮忙。谢谢!

1 个答案:

答案 0 :(得分:0)

我为解决这个问题所做的是在MapView之上的视图中绘制自己的线条,因为我无法找到更好的方法。它工作正常,只需要很多工作。