ios - expand search region in MKlocalSearch mapkit -


i using mapkit , mklocalsearch search business locations within users current area. region doesnt seem large need , business locations not show in search unless set current location closer business. span 75 miles, suggestions on how expand region in code? new using mapkit , have been unable find helpful. heres search methods.

- (void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar {  // cancel previous searches. [localsearch cancel];  // perform new search. mklocalsearchrequest *request = [[mklocalsearchrequest alloc] init]; request.naturallanguagequery = searchbar.text; request.region = self.mapview.region;  [uiapplication sharedapplication].networkactivityindicatorvisible = yes; localsearch = [[mklocalsearch alloc] initwithrequest:request];  [localsearch startwithcompletionhandler:^(mklocalsearchresponse *response, nserror *error){      [uiapplication sharedapplication].networkactivityindicatorvisible = no;      if (error != nil) {         [[[uialertview alloc] initwithtitle:nslocalizedstring(@"map error",nil)                                     message:[error localizeddescription]                                    delegate:nil                           cancelbuttontitle:nslocalizedstring(@"ok",nil) otherbuttontitles:nil] show];         return;     }      if ([response.mapitems count] == 0) {         [[[uialertview alloc] initwithtitle:nslocalizedstring(@"no results",nil)                                     message:nil                                    delegate:nil                           cancelbuttontitle:nslocalizedstring(@"ok",nil) otherbuttontitles:nil] show];         return;     }      results = response;      [self.searchdisplaycontroller.searchresultstableview reloaddata]; }]; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [results.mapitems count]; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath  *)indexpath {  static nsstring *identifier = @"searchresultscell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:identifier]; if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:identifier]; }  mkmapitem *item = results.mapitems[indexpath.row];  cell.textlabel.text = item.name; cell.detailtextlabel.text = item.placemark.addressdictionary[@"street"];  return cell; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [self.searchdisplaycontroller setactive:no animated:yes];  mkmapitem *item = results.mapitems[indexpath.row];   [self.mapview setcentercoordinate:item.placemark.location.coordinate animated:yes];  [self.mapview setusertrackingmode:mkusertrackingmodenone];  } 

request.region = mkcoordinateregionmakewithdistance(self.mapview.userlocation.location.coordinate, 120701, 120701); // 120701 meters 75 miles 

or if have location already:

request.region = mkcoordinateregionmakewithdistance(location.coordinate, 120701, 120701); 

setting search region independently allows search large areas without expanding map.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -