[![CI Status](http://img.shields.io/travis/Brad Smith/MapSnap.svg?style=flat)](https://travis-ci.org/Brad Smith/MapSnap)
MapSnap requires at least iOS 8 and Swift 3.0
MapSnap is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MapSnap"
UIImageView
extensions to generate, cache, and set a map image based on a CLLocationCoordinate2D
let mapImageView = UIImageView(frame: .zero)
let latitude = 42.3601
let longitude = 71.0589
let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
mapImageView.setMapImage(with: coordinate)
Optionally specify:
- image size
- placeholder image to use while the map image is asynchronously generated
let size = CGSizeMake(width: UIScreen.main.bounds.width, height: 200.0)
let placeholderImage = UIImage(named: "my_placeholder_image")
mapImageView.setMapImage(with: coordinate, size: size, placeholderImage: placeholderImage)
MapSnapManager
may be used directly to generate and cache map images. The default image size is customizable and has a default value of:
public var defaultImageSize = CGSize(width: UIScreen.main.bounds.width, height: 150.0)
The default cache used is PINCache, but you can subsitute it with anything that conforms to the MapSnapCache
protocol:
public protocol MapSnapCache {
func object(for key: String) -> Any?
func set(object: NSCoding, for key: String)
}
Brad Smith, @bsmithers11
MapSnap is available under the MIT license. See the LICENSE file for more info.