Reputation: 5829
I have a MKMapView
in my app and currently I'm fetching the center point of this map by using:
longitude = mapView.centerCoordinate.longitude
latitude = mapView.centerCoordinate.latitude
but now instead of taking the center point of the map I want to take a specific point that is 100px below the top edge of my mapview. So normally I would use something like:
longitude = mapView.centerCoordinate.longitude
latitude = mapView.(centerCoordinate+100px).latitude
But that's not how that works apparently. Is there any way of fetching a specific point from mkmapview?
Upvotes: 0
Views: 49
Reputation: 93141
Try this:
let frame = mapView.frame
let myPoint = CGPointMake(frame.midX, 100)
let myCoordinate = mapView.convertPoint(myPoint, toCoordinateFromView: mapView)
let annotation = MKPointAnnotation()
annotation.coordinate = myCoordinate
annotation.title = "My Point"
mapView.addAnnotation(annotation)
Upvotes: 1