I'm writing an application in Swift, and using Parse as the back-end.
In order to setup a query to Parse, I want to get the southwest-most point and northeast-most point displayed on the current MKMapView.
I currently get these values as displayed here:
//___ To calculate the search bounds, first we need to calculate the corners of the map
let nePoint = CGPointMake(self.myMap.bounds.origin.x + myMap.bounds.size.width, myMap.bounds.origin.y);
let swPoint = CGPointMake((self.myMap.bounds.origin.x), (myMap.bounds.origin.y + myMap.bounds.size.height));
//___ Then transform those point into lat, lng values
let neCoord = myMap.convertPoint(nePoint, toCoordinateFromView: myMap)
let swCoord = myMap.convertPoint(swPoint, toCoordinateFromView: myMap)
let neGP = PFGeoPoint(latitude: neCoord.latitude, longitude: neCoord.longitude)
let swGP = PFGeoPoint(latitude: swCoord.latitude, longitude: swCoord.longitude)
var query = PFQuery(className: "locations")
//___ Limit what could be a lot of points.
query.limit = 25
query.whereKey("location", withinGeoBoxFromSouthwest: swGP, toNortheast: neGP)
This works perfectly until the map is rotated.
However, once the user rotates the map, the top-right and bottom-left points no longer represent the northeast-most and southwest-most points.
How can I always calculate the true southwestern-most and northeastern-most points displayed on the map?
Thanks.