How to display an image on a MKOverlayView?

前端 未结 6 1176
故里飘歌
故里飘歌 2020-12-05 00:59

UPDATE:

Images who are projected on the MKMapView using a MKOverlayView use the Mercator projection, while the image that I use as input data uses

6条回答
  •  半阙折子戏
    2020-12-05 01:38

    Your image/overlay is most likely no longer proportional (i.e. it's been stretched). I've seen this kind of thing in my own app where the center of the view is correct, but as you go away from the equator toward either pole (top and bottom of screen) the map/overlay becomes increasingly distorted.

    You are obviously scaling your image by scaleFactor. I'd take a look at that for starters.

    size_t width    = (CGImageGetWidth(imageReference) / self.scaleFactor);
    size_t height   = (CGImageGetHeight(imageReference) / self.scaleFactor);
    

    Another good way to test your code to see if scaling is the culprit, is to scale your MKMapView down to the size of the overlay image. Leave the overlay image alone, and if it is no longer distorted then you know that is the problem.

提交回复
热议问题