MKMapView Zoom and Region

前端 未结 5 1036
旧时难觅i
旧时难觅i 2020-11-27 09:33

I\'m familiar with using Google Maps Javascript API. Recently I started using MapKit framework for an iphone project, but I\'m having a hard time to figure out zooming and s

5条回答
  •  迷失自我
    2020-11-27 09:54

    Brant's category on MKMapView works well. However, it appears that it has not been updated to support newer devices with retina screens when calculating mapSizeInPixels.

    It can be fixed by replacing this line:

    CGSize mapSizeInPixels = mapView.bounds.size;
    

    With this line:

    CGSize mapSizeInPixels = CGSizeMake(mapView.bounds.size.width * [UIScreen mainScreen].scale, mapView.bounds.size.height * [UIScreen mainScreen].scale);
    

提交回复
热议问题