When I know the latitudes and longitudes of center, and how could I get the latitudes and longitudes of top-left、top-right、bottom-right and bottom-left pxiel?
Fox example,it just like the picture:
How could I do with it? Thanks very much!
Try the following methods. basic idea taken from https://stackoverflow.com/a/44182763/2299040
extension MKMapView {
func topLeftCoordinate() -> CLLocationCoordinate2D {
return convert(CGPoint(x: 0, y: 0), toCoordinateFrom: self)
}
func topRightCoordinate() -> CLLocationCoordinate2D {
let x = frame.minX + frame.width
return convert(CGPoint(x: x, y: 0), toCoordinateFrom: self)
}
func bottomLeftCoordinate() -> CLLocationCoordinate2D {
let y = frame.minY + frame.height
return convert(CGPoint(x: 0, y: y), toCoordinateFrom: self)
}
func bottomRightCoordinate() -> CLLocationCoordinate2D {
let x = frame.minX + frame.width
let y = frame.minY + frame.height
return convert(CGPoint(x: x, y: y), toCoordinateFrom: self)
}
}