mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-23 03:36:34 +10:00
cache mapImage in FeedView
This commit is contained in:
@@ -336,30 +336,6 @@ class FeedSocialWorkCell: FeedBasicCell {
|
||||
self?.locationMapImageView.image = image
|
||||
})
|
||||
|
||||
/*
|
||||
let options = MKMapSnapshotOptions()
|
||||
options.scale = UIScreen.mainScreen().scale
|
||||
let size = CGSize(width: UIScreen.mainScreen().bounds.width - 65 - 60, height: 110 - locationNameLabel.bounds.height)
|
||||
options.size = size
|
||||
options.region = MKCoordinateRegionMakeWithDistance(locationCoordinate, 500, 500)
|
||||
|
||||
let mapSnapshotter = MKMapSnapshotter(options: options)
|
||||
|
||||
mapSnapshotter.startWithCompletionHandler { (snapshot, error) -> Void in
|
||||
if error == nil {
|
||||
|
||||
guard let snapshot = snapshot else {
|
||||
return
|
||||
}
|
||||
|
||||
let image = snapshot.image
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) { [weak self] in
|
||||
self?.locationMapImageView.image = image
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
locationNameLabel.text = locationInfo.name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,28 +421,10 @@ class FeedView: UIView {
|
||||
|
||||
if let locationCoordinate = feed.locationCoordinate {
|
||||
|
||||
let options = MKMapSnapshotOptions()
|
||||
options.scale = UIScreen.mainScreen().scale
|
||||
let size = CGSize(width: UIScreen.mainScreen().bounds.width - 65 - 60, height: 80 - locationNameLabel.bounds.height)
|
||||
options.size = size
|
||||
options.region = MKCoordinateRegionMakeWithDistance(locationCoordinate, 500, 500)
|
||||
|
||||
let mapSnapshotter = MKMapSnapshotter(options: options)
|
||||
|
||||
mapSnapshotter.startWithCompletionHandler { (snapshot, error) -> Void in
|
||||
if error == nil {
|
||||
|
||||
guard let snapshot = snapshot else {
|
||||
return
|
||||
}
|
||||
|
||||
let image = snapshot.image
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) { [weak self] in
|
||||
self?.locationMapImageView.image = image
|
||||
}
|
||||
}
|
||||
}
|
||||
ImageCache.sharedInstance.mapImageOfLocationCoordinate(locationCoordinate, withSize: size, completion: { [weak self] image in
|
||||
self?.locationMapImageView.image = image
|
||||
})
|
||||
}
|
||||
|
||||
locationNameLabel.text = feed.locationName
|
||||
|
||||
Reference in New Issue
Block a user