0

I'm working on an app that lets a user select locations on a map. The entire map is subdivided into irregular regions (administrative boundaries), and when a user touches a point on a map, I need to be able to figure out which region the point belongs to. Just to clarify, there is no finite set of points for a user to choose from, they just tap anywhere on the map.

What is the best way to achieve this? I have been looking at MKPolygon class but cannot really figure out if this is the way to go. If it is, would I be using intersectsMapRect: method of the MKOverlay protocol to check for a match? Are there any good tutorials on this kind of map operations?

SaltyNuts
  • 5,068
  • 8
  • 48
  • 80

1 Answers1

1

A good approach here might be the MapBox iOS SDK and it's RMInteractiveSource, which is designed for this. Check out this sample app which shows interactive regions.

This is done by a space-optimized, offline-capable key-value store of sorts that keys pixels at varying zoom levels to arbitrary content values (region name, data, imagery, etc.)

In MapKit proper, you'll need some sort of spatial analysis (maybe Spatialite?) to determine intersections between points touched and irregularly-shaped regions.

incanus
  • 5,100
  • 1
  • 13
  • 20
  • I ended up using a method described here: http://stackoverflow.com/questions/4354130/how-to-determine-if-an-annotation-is-inside-of-mkpolygonview-ios but depending how the project progresses, might look into MapBox as well if I need more complex customizations. – SaltyNuts Oct 17 '13 at 13:52