Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MapSnap/Classes/MKMapSnapshotter+MapSnap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import MapKit
public typealias MapSnapshotterCompletion = (UIImage?, NSError?) -> Void

public extension MKMapSnapshotter {
static func image(for coordinate: CLLocationCoordinate2D, size: CGSize, completion: MapSnapshotterCompletion?) {
let span = MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)
static func image(for coordinate: CLLocationCoordinate2D, size: CGSize, span: MKCoordinateSpan, completion: MapSnapshotterCompletion?) {

let region = MKCoordinateRegion(center: coordinate, span: span)

let options = MKMapSnapshotOptions()
Expand Down
6 changes: 4 additions & 2 deletions MapSnap/Classes/MapSnapManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open class MapSnapManager {

open var defaultImageSize = CGSize(width: UIScreen.main.bounds.width, height: 150.0)
open var cache: MapSnapCache?
open var defaultMapSpan = MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)

fileprivate var pendingOperationIDs = [UUID]()
}
Expand All @@ -31,9 +32,10 @@ public extension MapSnapManager {
pendingOperationIDs.remove(at: index)
}

func image(for coordinate: CLLocationCoordinate2D, size: CGSize? = nil, completion: MapSnapImageCompletion?) -> UUID? {
func image(for coordinate: CLLocationCoordinate2D, size: CGSize? = nil, span: MKCoordinateSpan? = nil, completion: MapSnapImageCompletion?) -> UUID? {
let cache = self.cache ?? PINCache.shared()
let imageSize = size ?? defaultImageSize
let mapSpan = span ?? defaultMapSpan

let key = [
String(describing: coordinate),
Expand Down Expand Up @@ -64,7 +66,7 @@ public extension MapSnapManager {

pendingOperationIDs.append(operationID)

MKMapSnapshotter.image(for: coordinate, size: imageSize, completion: snapshotCompletion)
MKMapSnapshotter.image(for: coordinate, size: imageSize, span: mapSpan, completion: snapshotCompletion)

return operationID
}
Expand Down