ios - How to Add the geofence of a region to monitoring. -


- (void)locationmanager:(cllocationmanager *)manager       didupdatelocations:(nsarray *)locations {      // if it's relatively recent event, turn off updates save power     nslog(@"%@ locations",locations);      float lat = _locationmanager.location.coordinate.latitude;     float long = _locationmanager.location.coordinate.longitude;      nslog(@"lat : %f  long : %f",lat,long);      cllocationcoordinate2d center = cllocationcoordinate2dmake(28.52171,77.2015457);      nslog(@"center check %@",center);     clcircularregion *region = [[clcircularregion alloc] initwithcenter:center                                                                  radius:500                                                              identifier:@"new region"];     bool doesitcontainmypoint = [region containscoordinate:cllocationcoordinate2dmake(lat,long)];      nslog(@"success %hhd", doesitcontainmypoint);  } 

the issue ,here m providing static region m checking (center) requirement is, region take lat n long of riders , riders can vary in number

i hv lat n long in array of dictionary. first driver pick first rider in list , @ time need region of rider 1 location. m not getting idea how achieve this

if this

for (nsmutabledictionary * dict in goerslist)     {         rider_id=[dict valueforkey:@"trip_id"];         lat=[dict valueforkey:@"origin_lat"];         longi=[dict valueforkey:@"origin_long"];  } 

then how know first region monitored , after existing range hv check second location

you can create dynamically regions , add them monitoring.

for (nsdictionary *dict in [result valueforkey:@"geofences"]) {     nslog(@"%@",dict);     cllocationcoordinate2d locationcoordinate=cllocationcoordinate2dmake([[dict valueforkey:@"clatitude"]doublevalue], [[dict valueforkey:@"clongitude"]doublevalue]);      clcircularregion *circularregion=[[clcircularregion alloc]initwithcenter:locationcoordinate radius:[[dict valueforkey:@"radius"]doublevalue] identifier:[dict valueforkey:@"name"]];      circularregion.notifyonentry=yes;     circularregion.notifyonexit=yes;     [[appdelegate shareddelegate].locationmanager startmonitoringforregion:circularregion];     nslog(@"%@",[[[appdelegate shareddelegate] locationmanager].monitoredregions description]); } 

here there several regions added monitoring. can add single @ time. i.e on selection of tableview.

and remove others using below code

for (clregion *monitored in [[appdelegate shareddelegate].locationmanager monitoredregions]) {     [[appdelegate shareddelegate].locationmanager stopmonitoringforregion:monitored]; } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -