I am new to iOS and I have to make an application in which the the user will know its present location and will enter a value in Kilometers and I have to find out that whether another given pair of latitude and longitude (which give a location on map) is within the given range. Please suggest if we have any function which can used to achieve this.
Asked
Active
Viewed 201 times
2 Answers
1
You obtain user location via CLLocationManager or via MapView's userLocation.
Then you may create a CLRegion
and use it's – containsCoordinate:
method, like:
CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:centerCoord radius:radius identifier:@""];
BOOL isInside = [region containsCoordinate:yourCoord]

MANIAK_dobrii
- 6,014
- 3
- 28
- 55
1
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location
CLLocationDistance is a typedef for double (in meters)
Convert that to kilometers and compare it to the given value.

Marc
- 6,051
- 5
- 26
- 56