View Full Version : pointForCoordinate incorrect when map in 3D mode

23.05.2016, 22:22

I've noticed that SKMapView method 'pointForCoordinate' returns an incorrect CGPoint when the map is in 3D mode. For example when I print out pointForCoordinate for a location which I know is on the map in 3D mode (because I put an annotation there and I see it) I get a CGPoint like (-300, -400). It seems as if that's the CGPoint i would get if the map would be in 2Dmode. (the 3D map shows more map area then the 2D at the same zoom level because the 3D map is not a square but a trapezium. The closer to the horizon the wider the visible area).

I know there should be a smart way to convert/transform the CGPoint I'm getting (where the annotation would show in 2D mode) to the CGPoint where the Annotation is displayed in 3D mode. (Probably with a very smart (vector?) transformation formula using SKCameraSettings' center, tilt and distance and probably SKMapView.visibleRegion's zoomLevel). However have not been able to crack this so far.

Is there any way someone could provide me with that smart formula? I'm assuming inside the framework implementation a formula like this (or reverse of it) is used to display the map in 3D mode.

Thanks in advance. Any help would be appreciated.

Best Regards,

10.08.2016, 16:36
For the users that are wondering if this is supported out of the box the answer is no. Until 3.0, as previously stated in our documentation: "the pointForCoordinate converts a CLLocationCoordinate2D location to a screen point of the current map view, if the location is in the current map region bounds."

@Guidove: we'll add an improvement for the future updates.