Skip to content

Instantly share code, notes, and snippets.

Dion Crannitch dionc

Block or report user

Report or block dionc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dionc / MapKitExtensions.swift
Last active Oct 1, 2018
Create an MKCoordinateRegion from an array of coordinates. Safely handles coordinates that cross the 180th meridian.
View MapKitExtensions.swift
import MapKit
extension MKCoordinateRegion {
init?(coordinates: [CLLocationCoordinate2D]) {
// first create a region centered around the prime meridian
let primeRegion = MKCoordinateRegion.region(for: coordinates, transform: { $0 }, inverseTransform: { $0 })
// next create a region centered around the 180th meridian
You can’t perform that action at this time.