2012-11-28 23 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) 
    } 
}