0

I want to check if coordinates that I am obtaining using the Location Manager are within a certain region.

  1. How can I create a region out of coordinates on swift? I don't want to draw the layer on the map or anything. I would just need to create it in order to check whether my coordinates are inside or outside of the region

  2. When created, is there a special method to check whether coordinates are inside this region.

Would be great if you could point me in the right direction.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • If your region is circular, you can try out the contains method of CLCircularRegion. If your region is a polygon, and you have the coordinates, you can use a brute force approach by using the distance(from:) method of CLLocation. – Kunal Shah Oct 29 '17 at 00:03
  • How would I set up this region then? I have seen implementation for the circular region, but I haven't seen it for polygons. – konsti1337 Oct 29 '17 at 10:19

1 Answers1

1

You seem to be mixing things.

One thing is:

How to create a circular region. See here. You use this to create a region and then if you drive through this region, or drive away from this region, you get will get a callback.

The other

If you purely just want to 'know the distance between two points', then you don't need to use CLRegion, just use the distance function. See here

mfaani
  • 33,269
  • 19
  • 164
  • 293
  • What I have is a region that is confined by around 500 coordinates and creates a polygon. For this region I want to check whether or not the current coordinate is inside this polygon. – konsti1337 Oct 29 '17 at 10:17