objective c - Multiple info windows showing same text in iOS -


i have implemented infowindow show data of multiple markers. can display same data in info windows .

how show data related marker, there should no repetition ?

here code :

     (int = 0 ; < jsondatadict.count; ++) {         nsdictionary *newdict = [jsondatadict objectatindex:i ];          double latitude = [[newdict valueforkey:@"lat"]doublevalue];         double longitute = [[newdict valueforkey:@"lng"]doublevalue];         namestr = [newdict valueforkey:@"name"];         countjson = ;          cllocationcoordinate2d position = cllocationcoordinate2dmake(latitude, longitute);         gmsmarker *marker = [gmsmarker markerwithposition:position];         marker.title = [newdict valueforkey:@"name"];       //  marker.icon = [uiimage imagenamed:@"pin11.png"];         marker.icon = [self image:[uiimage imagenamed:@"pinpopoye.png"] scaledtosize:cgsizemake(75.0f, 60.0f)];         marker.appearanimation = kgmsmarkeranimationpop;         marker.infowindowanchor = cgpointmake(1.1, 0.70);         marker.map = self.mapview;         [self mapview:self.mapview markerinfowindow:marker];       } }  - (uiview *)mapview:(gmsmapview *)mapview markerinfowindow:(gmsmarker *)marker {    uiview *customview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 60, 25)];    customview.backgroundcolor = [uicolor colorwithred:71.0/255.0 green:65.0/255.0 blue:65.0/255.0 alpha:0.8];     customview.layer.cornerradius = 5;     customview.layer.maskstobounds = yes;      //  orange color ==== [uicolor colorwithred:254.0/255.0 green:165.0/255.0 blue:4.0/255.0 alpha:0.5];        uilabel *namelabel = [[uilabel alloc]initwithframe:cgrectmake(0, 0, 60, 10)];    namelabel.text = namestr;    namelabel.textcolor = [uicolor whitecolor];    namelabel.textalignment = nstextalignmentcenter;    namelabel.font = [uifont systemfontofsize:8.0];     [customview addsubview:namelabel];        return customview; } 

replace statement:

namelabel.text = namestr; 

with:

namelabel.text = marker.title; 

the problem using shared nsstring, namestr, gets overwritten @ each iteration of for loop. so, label share same string value when displayed. do:

namelabel.text = [namestr copy]; 

and should work -- think using namestr in code remnant of previous "hack".


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -