Animations for a dropped pin not working - iphone

When I drop a pin on my mkmapview the animation works fine and the pin drops from the top of the screen as expected. I color that pin red because I haven't verified it. However, if I verify the pin using some code that is called on calloutAccessoryControlTapped I change the color of the Pin to green.
When I next press on the map to drop another red pin the animation fails and the pin just appears. If I do it again (long press) a new pin appears and it's animation is fine. What could I have done to the annotation that causes this behavior.
Thanks for any insights of what could have gone wrong here...
Donie
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
static NSString * const kPinIdentifier = #"PinIdentifier";
MKPinAnnotationView *draggablePinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:kPinIdentifier];
if(!draggablePinView)
{
draggablePinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kPinIdentifier] autorelease];
draggablePinView.pinColor = MKPinAnnotationColorRed;
draggablePinView.animatesDrop = YES;
draggablePinView.canShowCallout = YES;
draggablePinView.draggable = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
draggablePinView.rightCalloutAccessoryView = rightButton;
}
else
{
draggablePinView.annotation = annotation;
draggablePinView.animatesDrop = YES;
}
return draggablePinView;
}
-(void)longPressGesture:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
CGPoint touchPoint = [gestureRecognizer locationInView:mapView];
CLLocationCoordinate2D touchMapCoordinate = [mapView convertPoint:touchPoint toCoordinateFromView:mapView];
[self dropPinWithCoords:touchMapCoordinate];
}
}
- (void)mapView:(MKMapView *)mapview annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[self getFromServer];
}
-(void) showLoc8CodeDetail:(LOC8Code *) loc8
{
// Open the view controller
viewLoc8ViewController *loc8view = [[viewLoc8ViewController alloc] initWithLoc8code:loc8];
[gMainViewController.navigationController pushViewController:loc8view animated:YES];
[loc8view release];
}
-(void) dropPinWithCoords:(CLLocationCoordinate2D)loc
{
// Set the loc8code from index 0 in the global array and populate from response
LOC8Code *newPin = [gMapAnnotations objectAtIndex:0];
newPin.starRating = 1;
newPin.title = #"Unverified Pin";
newPin.subtitle = #"Click to verify postcode";
newPin.verified = NO; // this means you do have to requery if opened
newPin.coordinate = loc;
[self removeMapAnnotations];
[gMapAnnotations replaceObjectAtIndex:1 withObject:newPin];
[self.mapView addAnnotation:[gMapAnnotations objectAtIndex:1]];
// Reset flags
[dropPinButton setTitle:#"Replace Pin" forState:UIControlStateNormal];
[self moveAndHidePinButtons:NO];
}
-(void)getFromServer
{
[self checkRegisteredFromServer]; // Does API call to see if device already registered
// Get the loc8 code from the global array (pin always index 1)
LOC8Code *loc8 = [gMapAnnotations objectAtIndex:1];
// If we have a verified pin already (from a search) just show the info
if(loc8.verified == YES)
{
[self showLoc8CodeDetail:loc8];
}
else
{
[self setSpinning:YES];
// Get coordinates
NSString *urlWithCoords = [NSString stringWithFormat:#"https://www.server.com/api/rest/lite/loc?t=%#&u=%#&a=iloc8er&la=%f&lo=%f",
[Util getAPIToken], [UIDevice currentDevice].uniqueIdentifier,
loc8.coordinate.latitude,
loc8.coordinate.longitude];
NSLog(#"%#", urlWithCoords);
ASIHTTPRequest *request = [self populateRequest:request withURL: urlWithCoords];
[request setDidFinishSelector:#selector(loc8returned:)];
[[self networkQueue] addOperation:request];
}
}
-(void)loc8returned:(ASIHTTPRequest *)request
{
#try
{
NSString *response = [request responseString];
NSLog(#"RSP: %#", response);
// Store incoming data into an NSDictionary
SBJsonParser *parser = [[SBJsonParser new]autorelease];
NSDictionary *results = [parser objectWithString:response error:nil];
// Check for errors
NSNumber *r = [results objectForKey:#"r"];
NSString *e = [results valueForKey:#"e"];
if(r.boolValue == NO)
{
if([e isEqualToString:#"lc51"] || [e isEqualToString:#"lc52"])
{
// Outside range
[self setSpinning:NO];
return;
}
if([e isEqualToString:#"ud04"])
{
// quota check
[self setSpinning:NO];
return;
}
}
else
{
LOC8Code *loc8 = [gMapAnnotations objectAtIndex:1];
// Set the loc8code
NSString *lc = [results valueForKey:#"lc"];
loc8.postcode = lc;
loc8.verified = YES;
loc8.starRating = 0;
loc8.title = lc;
// This pin is now validated
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView viewForAnnotation:[gMapAnnotations objectAtIndex:1]];
pinView.pinColor = MKPinAnnotationColorGreen;
// Open the view controller
[self showLoc8CodeDetail:loc8];
}
}
#catch (NSException *exception)
{
[Util say:#"Service Temporarily Unavailable (-200):"];
NSLog(#"RSP: %#, %#", [exception name], [exception reason]);
}
[self setSpinning:NO];
}
The loc8code header class is defined as follows:
#interface LOC8Code : MKPlacemark {
NSString *postcode;
NSString *BusinessName;
int starRating;
CLLocationCoordinate2D coordinate_;
NSString *title_;
NSString *subtitle_;
BOOL verified; // Verified locations can't be moved (if pin moved then flag as not verified)
}
// Re-declare MKAnnotation's readonly property 'coordinate' to readwrite.
#property (nonatomic, retain) NSString *postcode;
#property (nonatomic, retain) NSString *BusinessName;
#property (nonatomic, assign) int starRating;
#property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;
#property (nonatomic, retain) NSString *title;
#property (nonatomic, retain) NSString *subtitle;
#property (nonatomic, assign) BOOL verified;
#end
And the implementation
#import "LOC8Code.h"
#implementation LOC8Code
#synthesize coordinate = coordinate_;
#synthesize title = title_;
#synthesize subtitle = subtitle_;
#synthesize verified;
#synthesize starRating;
#synthesize postcode;
#synthesize BusinessName;
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary {
if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary])) {
self.coordinate = coordinate;
}
return self;
}
- (void)dealloc {
[title_ release];
[subtitle_ release];
[postcode release];
[BusinessName release];
[super dealloc];
}
#end

It's probably due to the fact you're using the same reuse identifier all the time. Check out this line: static NSString * const kPinIdentifier = #"PinIdentifier";
That value needs to be unique for each pin you drop if all these pins are going to be different. I often use a comma-separated string of the latitude and longitude of a marker for my identifiers.

Related

unable to display custom Annotations on the map in iPhone

I am trying to add annotations on my mapview but I am not able to add them. Can someone suggest me where I am doing wrong? Code: Code to add the map:
mapview = [[MKMapView alloc] initWithFrame:CGRectMake(10, 175, 300, 268)];
mapview.delegate = self;
mapview.userInteractionEnabled = TRUE;
[mapview setZoomEnabled:TRUE];
[mapview setScrollEnabled:TRUE];
mapview.showsUserLocation = TRUE;
[self.view addSubview:mapview];
//adding annotations in another method:
for (id annotation in mapview.annotations) {
[mapview removeAnnotation:annotation];
}
for(int i =0;i<arrEventList.count;i++){
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = [[NSString stringWithFormat:#"%#",[(NSDictionary*)[arrEventList objectAtIndex:i] objectForKey:#"lat"]] floatValue];
theCoordinate.longitude = [[NSString stringWithFormat:#"%#",[(NSDictionary*)[arrEventList objectAtIndex:i] objectForKey:#"lng"]] floatValue];
MyLocation *annotation = [[[MyLocation alloc] initWithName:[(NSDictionary*)[arrEventList objectAtIndex:i] objectForKey:#"event"] address:[(NSDictionary*)[arrEventList objectAtIndex:i] objectForKey:#"place"] coordinate:theCoordinate] autorelease];
[mapview addAnnotation:annotation];
//[annotations addObject:myAnno.annotation];
}
// delegate method:
- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation {
static NSString *identifier = #"MyLocation";
if ([annotation isKindOfClass:[MyLocation class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image=[UIImage imageNamed:#"annotation.png"];//here we use a nice image instead of the default pins
return annotationView;
}
return nil;
}
Above delegate method is only called for self location but it is not called for other annotations that I want to add.
Can someone point me to my mistakes
#interface MyLocation : NSObject <MKAnnotation> {
NSString *_name;
NSString *_address;
CLLocationCoordinate2D _coordinate;
}
#property (copy) NSString *name;
#property (copy) NSString *address;
#property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate;
#end
//Mylocation class:
#implementation MyLocation
#synthesize name = _name;
#synthesize address = _address;
#synthesize coordinate = _coordinate;
- (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate {
if ((self = [super init])) {
_name = [name copy];
_address = [address copy];
_coordinate = coordinate;
}
return self;
}
- (NSString *)title {
if ([_name isKindOfClass:[NSNull class]])
return #"Unknown charge";
else
return _name;
}
- (NSString *)subtitle {
return _address;
}
I found the problem. My code is correct. The values of latittude and longitudes were some how interchanged. My mistake but I have corrected it now

iPhone map view custom annotation

I have some map view controller and I have a custom annotation.
Custom annotation code:
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>
#interface DisplayMapAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
NSString *detailID;
}
#property (nonatomic, assign) CLLocationCoordinate2D coordinate;
#property (nonatomic, retain) NSString *title;
#property (nonatomic, retain) NSString *subtitle;
#property (nonatomic, retain) NSString *detailID;
#end
#import "DisplayMapAnnotation.h"
#implementation DisplayMapAnnotation
#synthesize coordinate, title, subtitle, detailID;
- (NSString *) title
{
return title;
}
- (NSString *) subtitle
{
return subtitle;
}
- (NSString *) detailID
{
return detailID;
}
- (id)initWithCoordinate:(CLLocationCoordinate2D) c
{
coordinate=c;
return self;
}
- (void) dealloc
{
[title release];
[subtitle release];
[detailID release];
[super dealloc];
}
A here is my map view code where I create the annotation:
In viewDidLoad method I make something like this:
for (FeedItems *aItem in geoDataList) {
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [aItem.geoLat doubleValue];
region.center.longitude = [aItem.geoLng doubleValue];
region.span.longitudeDelta = kLatitudeDelta;
region.span.latitudeDelta = kLongitudeDelta;
[mapView setRegion:region animated:YES];
ann = [[DisplayMapAnnotation alloc] init];
ann.title = aItem.job;
ann.subtitle = aItem.jobCompany;
ann.detailID = aItem.jobID;
ann.coordinate = region.center;
[mapView addAnnotation:ann];
[aItem release];
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *pinView = nil;
if (annotation != self.mapView.userLocation) {
static NSString *defaultPinID = #"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil)
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
if (mapIdentifier == 0) {
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
//NSInteger annotationValue = [annView indexOfObject:annotation];
//rightButton.tag = annotationValue;
[rightButton addTarget:self action:#selector(detailButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
}
} else {
[self.mapView.userLocation setTitle:#"your location"];
}
return pinView;
}
And here is my problem (this method):
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(#"Detail id: %#", view.annotation.detailID);
}
When I will log detail id Xcode say: "Property 'detailID' not found on object of type 'id'" What is wrong ?
It does not know that the annotation is your custom annotation:
NSLog(#"Detail id: %#", view.annotation.detailID);
You could cast it like this to silence the warning
NSLog(#"Detail id: %#", [(DisplayMapAnnotation*)view.annotation detailID]);
after having checked that it is a DisplayMapAnnotation*
if ([view.annotation isKindOfClass:[DisplayMapAnnotation class]])

How to show multiple pin annotation in map?

I m showing a pin annotation statically, but i want to do it dynamically to show a lot of pins on map with title and subtitle.
Thx in advance.
I have an array of dictionaries with have two objects lat, long and i am doing this -
if ([resultArray count])
{
for (int i =0; i < [resultArray count]; i++)
{
NSDictionary *dict = [resultArray objectAtIndex:i];
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [[dict objectForKey:#"lat"] floatValue];
region.center.longitude = [[dict objectForKey:#"long"] floatValue];
region.span.longitudeDelta = 70.0f;
region.span.latitudeDelta = 70.0f;
MyAnnotations *ann = [[MyAnnotations alloc] init];
ann.title = #"title";
ann.coordinate = region.center;
[mapView addAnnotation:ann];
}
}
//
// MyAnnotation.h
//
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface MyAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
#property (nonatomic, assign) CLLocationCoordinate2D coordinate;
#property (nonatomic, copy) NSString *title;
#property (nonatomic, copy) NSString *subtitle;
#end
//
// MyAnnotation.m
//
#import "MyAnnotation.h"
#implementation MyAnnotation
#synthesize coordinate,title,subtitle;
-(void)dealloc
{
[title release];
[subtitle release];
[super dealloc];
}
#end
use this delegate for callout -
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation
{
MKPinAnnotationView *pinView = nil;
static NSString *defaultPinID = #"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil )
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorPurple;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self action:#selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = infoButton;
[defaultPinID release];
return pinView;
}

Customize map annotations from plist

I found a short guide on how to load "annotation data" from a plist and add those annotations (pins) to a MapView.
My question is if anyone can tell me how I would customize the pins the most easily? As an example, I would like to define a color and an image in the plist and then have it set when adding the pins.
The pins are added like this:
MyAnnotation.m:
#implementation MyAnnotation
#synthesize title, subtitle, coordinate;
-(void) dealloc {
[super dealloc];
self.title = nil;
self.subtitle = nil;
}
MyAnnotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface MyAnnotation : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
#property (nonatomic, assign) CLLocationCoordinate2D coordinate;
#property (nonatomic, copy) NSString* title;
#property (nonatomic, copy) NSString* subtitle;
Running through the plist in ViewDidLoad in MapViewController.m (array containg dictionaries for each pin) and adding annotations.
NSString *path = [[NSBundle mainBundle] pathForResource:#"Annotations" ofType:#"plist"];
NSMutableArray* anns = [[NSMutableArray alloc] initWithContentsOfFile:path];
for(int i = 0; i < [anns count]; i++) {
float realLatitude = [[[anns objectAtIndex:i] objectForKey:#"latitude"] floatValue];
float realLongitude = [[[anns objectAtIndex:i] objectForKey:#"longitude"] floatValue];
MyAnnotation* myAnnotation = [[MyAnnotation alloc] init];
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = realLatitude;
theCoordinate.longitude = realLongitude;
myAnnotation.coordinate = theCoordinate;
myAnnotation.title = [[anns objectAtIndex:i] objectForKey:#"title"];
myAnnotation.subtitle = [[anns objectAtIndex:i] objectForKey:#"subtitle"];
[mapView addAnnotation:myAnnotation];
[annotations addObject:myAnnotation];
[myAnnotation release];
}
EDIT:
I have added the viewForAnnotation method which sets the color but how can I set the color of each pin individually?
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation) {
static NSString *defaultPinID = #"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorPurple;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
}
else {
[mapView.userLocation setTitle:#"I am here"];
}
return pinView;
}
Solved! It can be done like this in the viewForAnnotation method:
for(MyAnnotation* a in mapView.annotations) {
if(annotation == a && annotation != mapView.userLocation) {
pinView.image = [UIImage imageNamed:a.annImage];
}
}

mapkit , tagging a disclosure button with index of annotation

i have been struggling with this for a few days, i even re-wrote half the code to try it another way.
i have my annotations imported from a csv, and placed onto the map with tile and subtitle, i am trying in vain to add a tag to disclosue buttons so i can see which one was tapped, but having problems, whatever values i assign to the annotation i cant seem to access them (like the index) i can access the title and subtitle, but thats it.
how do i assign a index to the annotation that i can then add to the button as a tag, so i can record the tap
here is my code
NSURL *dataUrl = [NSURL URLWithString:#"http://nne.ezadspro.co.uk/cms/testmap.txt"];
// URLWithString:#"http://neic.usgs.gov/neis/gis/qed.asc"];
NSString *fileString = [NSString stringWithContentsOfURL:dataUrl
encoding:NSUTF8StringEncoding
error:nil];
int count = 0;
NSScanner *scanner = [NSScanner scannerWithString:fileString];
points = [[NSMutableArray array] retain];
AnnotationData *event;
NSString *line;
NSArray *values;
while ([scanner isAtEnd] == NO) {
[scanner scanUpToString:#"\n" intoString:&line];
//skip the first line
if(count > 0) {
values = [line componentsSeparatedByString:#","];
event = [[[AnnotationData alloc] init] autorelease];
event.latitude = [[values objectAtIndex:5] floatValue];
event.longitude = [[values objectAtIndex:6] floatValue];
event.companyID = [[values objectAtIndex:0]intValue];
event.title = [values objectAtIndex:1];
event.subtitle = [values objectAtIndex:2];
//event.magnitude = [[values objectAtIndex:4] floatValue];
//event.depth = [[values objectAtIndex:5] floatValue];
//NSLog(#"%#",event.companyID);
[points addObject:event];
}
count++;
if(count == 300) {
//limit number of events to 300
break;
}
}
for (int i=0; i<points.count; i++) {
AnnotationData *annData = [points objectAtIndex:i];
coordinate.latitude = annData.latitude;
coordinate.longitude = annData.longitude;
CLLocationCoordinate2D newCoord = {coordinate.latitude, coordinate.longitude};
PlaceAnnotation* annotation = [[PlaceAnnotation alloc] initWithCoordinate:newCoord andID:i];
annotation.mTitle = annData.title;
annotation.mSubtitle = annData.subtitle;
annotation.indexID = i;
//annotation.indexID = [[i]intValue];
[mapView addAnnotation:annotation];
[annotation release];
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *pinAnnotation = nil;
if(annotation != mV.userLocation)
{
static NSString *defaultPinID = #"myPin";
pinAnnotation = (MKPinAnnotationView *)[mV dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinAnnotation == nil )
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinAnnotation.canShowCallout = YES;
//instatiate a detail-disclosure button and set it to appear on right side of annotation
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnotation.rightCalloutAccessoryView = infoButton;
//infoButton.tag =
//[infoButton addTarget:self action:#selector(onMapVenueSelect) forControlEvents:UIControlEventTouchUpInside];
//defaultPinID.rightCalloutAccessoryView = infoButton;
//infoButton.tag = [event indexOfObject:tmpVenueData];
// [defaultPinID release];
}
return pinAnnotation;
[pinAnnotation release];
}
thanks
Consider using the MKAnnotation protocol and storing whatever you need ID or data wise your object.
A starting point header might go something like this:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#interface YourFancyAnnotationClass : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
NSNumber *companyID;
}
#property(nonatomic, assign) CLLocationCoordinate2D coordinate;
#property(nonatomic, copy) NSString *title;
#property(nonatomic, copy) NSString *subtitle;
#property(nonatomic, copy) NSNumber *companyID;
#end
Then in your delegate do something like this...
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(#"calloutAccessoryControlTapped:");
YourFancyAnnotationClass *tappedSite = (SiteAnnotation *)[view annotation];
NSNumber *companyIDThatWasClickedExample = [tappedSite companyID];
etc...