0

There is a extremely weird problem in my app. I am developing an app that records user's trail and draws them on a MKMapView (like Runkeeper). A person in Asia used this app, and the person reported that the MKPolylines on the MKMapViews actually render at wrong positions, at an offset of what the correct positions should be. When I tested this app in North America, the MKPolyline is not rendered wrongly. Is this because the conversion between CLLocationCoordinate2D and MKMapPoint is inaccurate? Does it have to do with the 180 meridian thingies? Thank you so very much.

Code (I could not really find what is wrong in this code, but maybe you can?):

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

Blip
  • 1,158
  • 1
  • 14
  • 35
  • 1
    If this is in China, see http://stackoverflow.com/questions/12511588/how-to-deal-with-inconsistent-chinese-maps-on-ios-6. –  Apr 08 '15 at 00:51
  • @Anna Yes yes, it is indeed in china. I heard this is because China has an encrypted maps coordinate system. Do you know if there are other cases like this in other countries? Thanks very much. – Blip Apr 08 '15 at 01:11

0 Answers0