#import "POL.h"
@implementation MatchProfile_MapController
@synthesize intTag1;
- (void)viewDidLoad {
self.navigationItem.title=@"Select Person";
appdelegate=[[UIApplication sharedApplication]delegate];
for(int i=0;i<[appdelegate.arrayRecentCompatible count];i++)
{
NSMutableDictionary *dic=[appdelegate.arrayRecentCompatible objectAtIndex:i];
CLLocationCoordinate2D coord;
coord.latitude =[[dic valueForKey:@"Latitude"] doubleValue];
coord.longitude =[[dic valueForKey:@"Longitude"] doubleValue];
POL *poi = [[POL alloc] initWithCoords:coord];
poi.title =[dic valueForKey:@"Name"];
poi.subtitle =[dic valueForKey:@"Country"];
poi.img1=[UIImage imageNamed:[dic valueForKey:@"Image"]];
poi.intTag=i;
[mapView addAnnotation:poi];
}
mapView.delegate=self;
MKCoordinateRegion zoomIn = mapView.region;
zoomIn.span.latitudeDelta *=5;
[mapView setRegion:zoomIn animated:YES];
[super viewDidLoad];
}
- (MKAnnotationView *) mapView:mapView viewForAnnotation:(id
{
newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@""];
[newAnnotation setPinColor:MKPinAnnotationColorGreen];
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
POL *TempPOL=(POL*) annotation;
UIButton *btnRow1=[[UIButton buttonWithType:UIButtonTypeCustom]retain];
btnRow1.frame=CGRectMake(0, 0, 25, 30);
[btnRow1 setBackgroundImage:TempPOL.img1 forState:UIControlStateNormal];
[btnRow1 addTarget:self action:@selector(selectUSer:) forControlEvents:UIControlEventTouchUpInside];
btnRow1.tag=TempPOL.intTag;
newAnnotation.leftCalloutAccessoryView=btnRow1;
UIButton *btnRow2=[[UIButton buttonWithType:UIButtonTypeDetailDisclosure]retain];
[btnRow2 addTarget:self action:@selector(selectUSer:) forControlEvents:UIControlEventTouchUpInside];
btnRow2.tag=TempPOL.intTag;
newAnnotation.rightCalloutAccessoryView=btnRow2;
return newAnnotation;
}
#pragma mark -
#pragma mark Memory methods
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
- (void)dealloc {
[super dealloc];
}
#pragma mark -
#pragma mark Methods
-(IBAction)selectUSer:(id)sender
{
if(objProfile==nil)
objProfile=[[ProfileViewController alloc]initWithNibName:@"ProfileViewController" bundle:nil];
for(int i=0;i<4;i++)
{
NSMutableDictionary *dic=[appdelegate.arrayRecentCompatible objectAtIndex:i];
UIButton *btn=(UIButton*)sender;
if(btn.tag==i)
{
objProfile.intPerson=i;
objProfile.strTitle=[dic valueForKey:@"Name"];
}
}
[self.navigationController pushViewController:objProfile animated:YES];
}
@end
This code for mapview in iPhone help me a lot. I would like to thank you for that.
ReplyDeleteI can say one thing for this, it solved my problem that i was facing to implement project on map in iphone. Thank you!
ReplyDeleteCan you help me out with more code like this. I need to implement more things on map in iPhone.
ReplyDelete