objective c - MKMapView pin animation and annotation -


i'm using google places api find restaurants nearby (based on current location using core location manager); currently, i'm able drop pins. use searchbarsearchbuttonclicked method, , inside of dispatch_async block, call method parse through serialized data , attribute values properties of pin class (class mkannotation). i'd animate pin drops, , display annotations...for reason had them working before won't show when click on pins.

view controller.h

@interface myviewcontroller : uiviewcontroller <cllocationmanagerdelegate, mkmapviewdelegate, uisearchbardelegate,nsurlsessiondelegate> {      cllocationmanager *locationmanager;  }  @property (strong, nonatomic) mkmapview *mapview;  @property (strong, nonatomic) uisearchbar *searchbar;  @property (strong, nonatomic) uiimageview *logo;  @property (strong, nonatomic) uitoolbar *toolbar;  @property (strong, nonatomic) nsstring *places;  @end 

view controller.m

-(void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar {     nslog(@"%@", self.searchbar.text);     nsurlsession *session = [nsurlsession sharedsession];     nsstring *s = [nsstring     stringwithformat:@"https://maps.googleapis.com/maps/api/place/nearbysearch/json?keyword=%@&location=%f,%f&radius=5&types=food&key=aizasycg6ahz_hq1f2rjkeawcjkqetblpvjhs-e", self.searchbar.text, locationmanager.location.coordinate.latitude, locationmanager.location.coordinate.longitude];      nsurl *url = [[nsurl alloc]initwithstring:s];      nsurlrequest *request = [[nsurlrequest alloc]initwithurl:url];      nsurlsessiondownloadtask *task = [session downloadtaskwithrequest:request completionhandler:^(nsurl *location, nsurlresponse *response, nserror *error) {         nsdata *dataresponse = [[nsdata alloc]initwithcontentsofurl:location];          nsdictionary *dictionaryreponse = [nsjsonserialization jsonobjectwithdata:dataresponse options:kniloptions error:&error];         nsmutablearray *finalresults = [dictionaryreponse objectforkey:@"results"];       dispatch_async(dispatch_get_main_queue(), ^{          [self placeannotations:finalresults];      });      }];     [task resume];  }  -(void)placeannotations:(nsmutablearray *)data {           (id<mkannotation> annotation in self.mapview.annotations) {             //        if ([annotation iskindofclass:[mappoint class]]) {             [self.mapview removeannotation:annotation];             //        }         }          (int = 0; < [data count]; i++) {             nsdictionary *place = [data objectatindex:i];             nsdictionary *geo = [place objectforkey:@"geometry"];             nsdictionary *location = [geo objectforkey:@"location"];             nsstring *name = [place objectforkey:@"name"];             nsstring *vicinity = [place objectforkey:@"vicinity"];             cllocationcoordinate2d placecoord;             placecoord.latitude = [[location objectforkey:@"lat"] doublevalue];             placecoord.longitude = [[location objectforkey:@"lng"] doublevalue];               mappoint *newpin = [mappoint new];             newpin.name = name;             newpin.address = vicinity;             newpin.coordinate = placecoord;              mkpinannotationview *newannotation = [[mkpinannotationview alloc]initwithannotation:newpin reuseidentifier:@"annotation"];             newannotation.animatesdrop = yes;              [self.mapview addannotation:newpin];          }           [self.mapview reloadinputviews];  } 

i


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -