0

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?

user3766930
  • 5,629
  • 10
  • 51
  • 104

2 Answers2

1

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)
Code Different
  • 90,614
  • 16
  • 144
  • 163
0

Used the the MapKit method:

convertPoint:toCoordinateFromView:
Ben M.
  • 39
  • 2