ios - Kindly guide me to Change the color and set image for annotation in MkMap -
i need alter color , in positions need set images annotation point. code displays reddish color annotation please guide me code bellow,
- (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. //map view webservice // nslog(@"%@",nam2); nsstring *urlmapstring=[nsstring stringwithformat:@"http://www.tranzlogix.com/tranzlogix_webservice/map.php?format=json&truckno=%@",nam2]; nsurl *urlmap=[nsurl urlwithstring:urlmapstring]; nsdata *datamap=[nsdata datawithcontentsofurl:urlmap]; nserror *errormap; nsdictionary *jsonmap = [nsjsonserialization jsonobjectwithdata:datamap options:kniloptions error:&errormap]; nsarray *resultsmap = [jsonmap valueforkey:@"posts"]; nsarray *resmap = [resultsmap valueforkey:@"post"]; nsarray *latitudestring=[resmap valueforkey:@"latitude"]; // nslog(@"%@", latitudestring); nsstring *latorgstring = [latitudestring objectatindex:0]; // nslog(@"%@", latorgstring); double latitude=[latorgstring doublevalue]; nsarray *longitudestring=[resmap valueforkey:@"longitude"]; // nslog(@"%@", longitudestring); nsstring *longorgstring = [longitudestring objectatindex:0]; // nslog(@"%@", longorgstring); double longitude=[longorgstring doublevalue]; // nslog(@"latdouble: %f", longitude); //map view point mkcoordinateregion myregion; //center cllocationcoordinate2d center; center.latitude=latitude; center.longitude=longitude; //span mkcoordinatespan span; span.latitudedelta=the_span; span.longitudedelta=the_span; myregion.center=center; myregion.span=span; //set our mapview [mapviewc setregion:myregion animated:yes]; //annotation //1.create coordinate utilize annotation cllocationcoordinate2d wimblocation; wimblocation.latitude=latitude; wimblocation.longitude=longitude; annotation * myannotation= [annotation alloc]; cllocation *somelocation=[[cllocation alloc]initwithlatitude:latitude longitude:longitude]; clgeocoder *geocoder = [[clgeocoder alloc] init]; [geocoder reversegeocodelocation:somelocation completionhandler:^(nsarray *placemarks, nserror *error) { nsdictionary *dictionary = [[placemarks objectatindex:0] addressdictionary]; // nslog(@"%@",dictionary); addressoutlet=[dictionary valueforkey:@"street"]; // nslog(@"%@",addressoutlet); city=[dictionary valueforkey:@"city"]; // nslog(@"%@",city); state=[dictionary valueforkey:@"state"]; // nslog(@"%@",state); myannotation.coordinate=wimblocation; if (addressoutlet!=null&&city!=null) { myannotation.title=addressoutlet; myannotation.subtitle=[nsstring stringwithformat:@"%@,%@", city, state]; } else if (addressoutlet==null&&city!=null) { myannotation.title=city; myannotation.subtitle=[nsstring stringwithformat:@"%@,%@", city, state]; } else if (addressoutlet!=null&&city==null) { myannotation.title=addressoutlet; myannotation.subtitle=[nsstring stringwithformat:@"%@", state]; } else if(addressoutlet==null&&city==null) { myannotation.title=state; myannotation.subtitle=[nsstring stringwithformat:@"%@",state]; } [self.mapviewc addannotation:myannotation]; }]; }
please guide me new xcode & objective-c
you need subclass mkannotationview , override couple of properties , methods set image of preference. since thats much of walk through managed fish out blog help that.
ios iphone annotations mkmapview mapkit
No comments:
Post a Comment