I have one task to develop application with map-kit.
I am getting multiple pins from server and one pin i have to drop from user current location. This user current location pin should be green & other pins which are coming from server should be in another color.How can i do this??
and another question is i am getting some pins on one another because there latitude & longitude have some minor differences. so at that particular point where the pins are going to be dropped on one another that point i want to give one button (on pin pop up window) which handle the minor difference of lat & long pins means the button tells next pin & as soon as the button pressed the pop up window should go on another pin which is not already selected & open its pop up window which also tells next pin. how can i do this??
i am using code like this for creating pin
for getting user loacation pin
Place* current = [[[Place alloc] init] autorelease];
current.name = @"You are here.";
current.latitude = coordinate.latitude;
current.longitude = coordinate.longitude;
PlaceMark *from = [[[PlaceMark alloc] initWithPlace:current] autorelease];
[mapView addAnnotation:from];
for getting server location pin.
int s=1;
for (j=0 ; j < i - 1 ; j++)
{
//points = [[NSString alloc] initWithFormat:@"point%d",s];
reports = [NSArray arrayWithArray:lat];
NSString *titles = [[NSString alloc] initWithFormat:@"%@",[tit objectAtIndex:j]];
NSString *description = [[NSString alloc] initWithFormat:@"%@",[des objectAtIndex:j]];
float latitude=[[lat objectAtIndex:j] floatValue];
float longitude=[[lon objectAtIndex:j] floatValue];
Place* home = [[[Place alloc] init] autorelease];
home.name = [NSString stringWithFormat:@"%@",titles];
home.description = [NSString stringWithFormat:@"%@",description];
home.latitude = latitude;
home.longitude = longitude;
PlaceMark *from = [[[PlaceMark alloc] initWithPlace:home] autorelease]; [mapView addAnnotation:from];
s++;
[self centerMap];
}
this code for creating there popup window.
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation{
if (annotation == mapView.userLocation)
return nil;
MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];
if (pin == nil)
pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] autorelease];
else
pin.annotation = annotation;
pin.userInteractionEnabled = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];
pin.rightCalloutAccessoryView = disclosureButton;
pin.pinColor = MKPinAnnotationColorRed;
pin.animatesDrop = YES;
[pin setEnabled:YES];
[pin setCanShowCallout:YES];
return pin;}
this code for handle there events means pin is calling the button action.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{ nslog (do something)
}
My all codes are working properly. i want just answer of above given questions..pls help me