My objective is to convert the top left and bottom right points of my view to lat/lon coordinates. These lat/lon coordinates will be used to query annotation locations that only exist within the view (not all 5000+).
I found this Objective-C tip on Stackoverflow. But the issue I have is that it is converting 0,0 from the mapView (a lat/lon of -180,-180. Aka, the Southpole).
So instead of:
topLeft = mapView.convertPoint(CGPointMake(0, 0), toCoordinateFromView: self.mapView)
I figured I could simply do:
topLeft = view.convertPoint(CGPointMake(0, 0), toCoordinateFromView: self.mapView)
But I get the error:
Cannot invoke 'convertPoint' with an argument list of type '(CGPoint, toCoordinateFromView: MKMapView!)'
I have spent a day trying to figure it out, but to no avail, and I have come to you seeking guidance. Any help would be much appreciated.
Here is the complete function:
func findCornerLocations(){
var topLeft = CLLocationCoordinate2D()
let mapView = MKMapView()
topLeft = view.convertPoint(CGPointMake(0, 0), toCoordinateFromView: self.mapView)
print(topLeft.latitude, topLeft.longitude)
}