iphone - How to set Radius for CLLocationManager in IOS -
i have requirement have show alert view user, when user cross radius point. how set radius.?
first need create region using:
cllocationdegrees latitude = <your_latitude>; cllocationdegrees longitude = <your_longitude>; cllocationcoordinate2d center = cllocationcoordinate2dmake(latitude, longitude); cllocationdistance radius = geo_fence_radius; clregion *region = [[clregion alloc]initcircularregionwithcenter:center radius:radius identifier:title];
next have monitor region by:
[locationmanager startmonitoringforregion:region];
then can track users when enter or exit following delegate methods:
- (void)locationmanager:(cllocationmanager *)manager didenterregion:(clregion *)region { //show alert entered region } - (void)locationmanager:(cllocationmanager *)manager didexitregion:(clregion *)region { //show alert exited region } - (void)locationmanager:(cllocationmanager *)manager didstartmonitoringforregion:(clregion *)region { } - (void)locationmanager:(cllocationmanager *)manager monitoringdidfailforregion:(clregion *)region witherror:(nserror *)error { }
Comments
Post a Comment