Skip to content

Easily create, cache, and access map snapshots on iOS

License

Notifications You must be signed in to change notification settings

bsmith11/MapSnap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapSnap

[![CI Status](http://img.shields.io/travis/Brad Smith/MapSnap.svg?style=flat)](https://travis-ci.org/Brad Smith/MapSnap) Version License Platform

Requirements

MapSnap requires at least iOS 8 and Swift 3.0

Installation

MapSnap is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MapSnap"

Usage

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)
}

Author

Brad Smith, @bsmithers11

License

MapSnap is available under the MIT license. See the LICENSE file for more info.

About

Easily create, cache, and access map snapshots on iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published