2

I am calling API and getting latitude, longitude, title and many other data and storing them into custom data structure. I get 20 results per request.

So i need to show only some of those 20 results into visible area of MKMapView. When user change the region of map, API call should be done and my custom data structure will be filled and again only in visible area annotation should be drawn.

I am calling API again into mapView:regionDidChangeAnimated method but i am not able to show annotation into visible Map area only.

Can anyone help me to figure out how I can show annotation into visible are only?

Note: This is a same question but for Objective-C and I don't understand the answer of @Shmidt, and how I can use that code.

Community
  • 1
  • 1
  • There are online code converters like [objectivec2swift](https://objectivec2swift.com/#/converter/code) – vadian Apr 27 '16 at 15:56

1 Answers1

0

MKMapView has attribute visibleMapRect, then you can use function MKMapRectContainsPoint

let point = CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)
let mapContainsPoint = MKMapRectContainsPoint(map.visibleMapRect, MKMapPointForCoordinate(point));`