2012-11-28 22 views

回答

5

MKMapView有两个属性可以实现这个功能:scrollEnabledzoomEnabled。设置为NO,你将有一个非滚动和非缩放(因此静态)地图图像。

+0

这也是我如何实现这一目标。 – Daniel

+0

不要忘了'pitchEnabled'和'rotateEnabled' –

2

我相信Google Static Maps是你在找什么。发送它的位置参数,它会返回你想要的图像。

+0

海报明确要求提供Apple地图图片... – DrMickeyLauer

+0

@DrMickeyLauer:我建议了一个替代方案,那有什么问题? Google静态地图提供了很多选项和更好的地图。 – Armin

+0

确实如此。没有错。 – DrMickeyLauer

1

在iOS 7+ Apple MapKit允许使用MKMapSnapshotter类显示地图的静态图像。在MapKit文档的Creating a Snapshot of a Map部分中有详细说明:

// Takes a snapshot and calls back with the generated UIImage 
static func takeSnapshot(mapView: MKMapView, withCallback: (UIImage?, NSError?) ->()) { 
    let options = MKMapSnapshotOptions() 
    options.region = mapView.region 
    options.size = mapView.frame.size 
    options.scale = UIScreen.mainScreen().scale 

    let snapshotter = MKMapSnapshotter(options: options) 
    snapshotter.startWithCompletionHandler() { snapshot, error in 
     guard snapshot != nil else { 
      withCallback(nil, error) 
      return 
     } 

     withCallback(snapshot!.image, nil) 
    } 
}