MKPolylineRenderer在全球另一边的MKMapView上呈现错误的位置?

时间:2015-04-07 21:44:09

标签: ios objective-c swift

我的应用中存在一个非常奇怪的问题。我正在开发一个记录用户踪迹的应用程序,并将它们绘制在MKMapView(如Runkeeper)上。亚洲的一个人使用这个应用程序,并且该人报告MKMapViews上的MKPolylines实际上呈现在错误的位置,与正确位置的偏移量。当我在北美测试这个应用程序时,MKPolyline没有被错误地渲染。这是因为CLLocationCoordinate2D和MKMapPoint之间的转换是不准确的吗?它与180经络物有关吗?非常感谢你。

代码(我无法真正找到此代码中的错误,但也许你可以吗?):

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    //...
    addLocationsToTrail(locations as [CLLocation])

    updateOverlay()
}

func addLocationsToTrail(locations: [CLLocation]) {
    for location in locations {
        locationsInTrailRecorded.addLocationToTrail(location)
    }
}

func updateOverlay() {
    let newOverlay = PolylineOverlayFactory.createPolylineOverlayFromLocations(locationsInTrailRecorded)   //Returns MKPolyline
    let oldOverlay = self.trailOverlay

    mapView.addOverlay(newOverlay, level: .AboveRoads)

    mapView.removeOverlay(oldOverlay)

    self.trailOverlay = newOverlay
}

enter image description here

0 个答案:

没有答案