Created
June 29, 2017 16:28
-
-
Save dgyesbreghs/0a8802acb78a3cb44beaaf837a520b83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MKMapRect+Conversion.swift | |
// | |
// Created by Dylan Gyesbreghs on 29/06/2017. | |
// Copyright © 2017 Dylan Gyesbreghs. All rights reserved. | |
// | |
import MapKit | |
extension MKMapRect { | |
var northEastCoordinate: CLLocationCoordinate2D { | |
return coordinateFromMapRectanglePoint(MKMapRectGetMaxX(self), origin.y) | |
} | |
var northWestCoordinate: CLLocationCoordinate2D { | |
return coordinateFromMapRectanglePoint(MKMapRectGetMinX(self), origin.y) | |
} | |
var southEastCoordinate: CLLocationCoordinate2D { | |
return coordinateFromMapRectanglePoint(MKMapRectGetMaxX(self), MKMapRectGetMaxY(self)) | |
} | |
var southWestCoordinate: CLLocationCoordinate2D { | |
return coordinateFromMapRectanglePoint(origin.x, MKMapRectGetMaxY(self)) | |
} | |
fileprivate func coordinateFromMapRectanglePoint(_ x: Double, _ y: Double) -> CLLocationCoordinate2D { //swiftlint:disable:this identifier_name line_length | |
let mapPoint = MKMapPoint(x: x, y: y) | |
return MKCoordinateForMapPoint(mapPoint) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment