Search Results

Search found 54 results on 3 pages for 'mkannotationview'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • iPhone MapKit problems: viewForAnnotation inconsistently setting pinColor?

    - by blackkettle
    Hi, I'm trying setup a map that displays different pin colors depending on the type/class of the location in question. I know this is a pretty common thing to do, but I'm having trouble getting the viewForAnnotation delegate to consistently update/set the pin color. I have a showThisLocation function that basically cycles through a list of AddressAnnotations and then based on the annotation class (bus stop, hospital, etc.) I set an if( myClass == 1){ [defaults setObject:@"1" forKey:@"currPinColor"]; [defaults synchronize]; NSLog(@"Should be %@!", [defaults objectForKey:@"currPinColor"]); } else if( myClass ==2 ){ [defaults setObject:@"2" forKey:@"currPinColor"]; [defaults synchronize]; NSLog(@"Should be %@!", [defaults objectForKey:@"currPinColor"]); } [_mapView addAnnotation:myCurrentAnnotation]; then my viewForAnnotation delegate looks like this, - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation { if( annotation == mapView.userLocation ){ return nil; } NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; MKPinAnnotationView *annView = nil; annView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"currentloc"]; if( annView == nil ){ annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; } annView.pinColor = [defaults integerForKey:@"currPinColor"]; NSLog(@"Pin color: %d", [defaults integerForKey:@"currPinColor"]); annView.animatesDrop=TRUE; annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5); return annView; } The problem is that, although the NSLog statements in the "if" block always confirm that the color has been set, the delegate sometimes but not always ends up with the correct color. I've also noticed that what generally happens is that the first search for a new location will set all pins to the last color in the "if" block, but search for the same location again will set the pins to the correct color. I suspect I am not supposed to usen NSUserDefaults in this way, but I also tried to create my own subclass for MKAnnotation which included an additional property "currentPinColor", and while this allowed me to set the "currentPinColor", when I tried to access the "currentPinColor from the delegate method, the compiler complained that it didn't know anything about "currentPinColor in connection with MKAnnotation. Fair enough I guess, but then I tried to revise the delegate method, - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation instead of the default - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation at which point the compiler complained that it didn't know anything about the protocol for MyCustomMKAnnotation in this delegate context. What is the proper way to set the delegate method and/or MyCustomMKAnnotation, or what is the appropriate way to achieve consistent pinColor settings. I'm just about out of ideas for things to try here.

    Read the article

  • MKMapView doesn't want to call didAddAnnotationViews method

    - by TheLearner
    I am writing a little map kit app but it doesn't want to call the delegate method didaddannotationviews: (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views { //Get the first MKAnnotationView from the views returned MKAnnotationView *annotationView = [views objectAtIndex:0]; //Get the annotation from the first annotation view and save it in a variable which can hold any object as long as it implements mkannotation id <MKAnnotation> mp = [annotationView annotation]; //Create a region MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250); //As the mapview to animate i.e. display the region [mv setRegion:region animated:YES]; } @interface WhereAmIAppDelegate : NSObject { UIWindow *window; CLLocationManager *locationManager; IBOutlet MKMapView *mapView; IBOutlet UIActivityIndicatorView *activityIndicator; IBOutlet UITextField *locationTitleField; }

    Read the article

  • iphone xcode annotation pin drop with slider value change also remove

    - by chirag
    i have to add annotation pin on location with UIslider Value change .... this is code where i add annotation (MKAnnotationView *) mapView:(MKMapView *)mapView1 viewForAnnotation:(id ) annotation{ MKAnnotationView* annotationView = nil; NSString* identifier = @"Pin"; MyAnnotationView* annView = (MyAnnotationView*)[mapView1 dequeueReusableAnnotationViewWithIdentifier:identifier]; // annotationView.leftCalloutAccessoryView = myImage; //myImage = [UIButton buttonWithType:UIButtonTypeCustom]; // [myImage setImage:[UIImage imageNamed:@"mark.png"]forState:UIControlStateNormal]; //Property_Photo UIButton *mybtn = [UIButton buttonWithType:UIButtonTypeCustom]; if([annotation isKindOfClass:[AddressAnnotation class]]){ AddressAnnotation x=(AddressAnnotation)annotation; mybtn.frame = CGRectMake(0, 0, 35, 35); mybtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; mybtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; [mybtn setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal]; [mybtn setTitle:[NSString stringWithFormat:@"%@",[x getID]] forState:UIControlStateDisabled]; [mybtn addTarget:self action:@selector(btnShowProperty:) forControlEvents:UIControlEventTouchUpInside]; ((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice = [[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Price"]; NSLog(@"property price: %@",((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice); if(nil == annView) { ///if(annView!=nil && [annView retainCount]>0){ [annView release]; annView=nil; } annView = [[[MyAnnotationView alloc] initWithAnnotation:x reuseIdentifier:identifier] autorelease]; if(Objslider.value==10){ [myMapView removeAnnotations:myMapView.annotations]; } } NSURL *imgURL = [NSURL URLWithString:[[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Photo"]]; UIImage *imgPhoto = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgURL]]; UIImageView *pinImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,35, 35)]; imgIndex++; [pinImgView setImage:imgPhoto]; annView.rightCalloutAccessoryView = mybtn; annView.leftCalloutAccessoryView = pinImgView; [annView setBackgroundColor:[UIColor clearColor]]; } [annView setEnabled:YES]; annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5); annotationView = annView; return annotationView; }

    Read the article

  • iPhone mapKit annotation for Current Location

    - by Simon
    Hello Im currently strugglung with annotations. how can i prevent the AnnotationLable for the blue GPS-point. (Here is an Image) - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(MKAnnotation *) annotation{ if (annotation == mapView.userLocation) { return nil; } the function above isnt working, and i realized that i can't compare two coordinates. Any hint is welcome. Simon

    Read the article

  • How to know when MKPinAnnotationView pin callout opens/closes

    - by JOM
    I want to update pin callout (popup) subtitle either realtime, when I receive some new info from server, or at least when callout opens. So far it looks like pin + callout are created only once at... - (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation ...and then used as-is as long as it exists regardless how many times I tap it closed/open or scroll around keeping it visible. How can I update the subtitle?

    Read the article

  • Uncenter MkMapView

    - by Makinitez21
    I am trying to "uncenter" the map view and remove all annotations. the reason for this is that the mapView will be used by different view controllers to display different annotations and locations. What's happening now is that i am using the "remove annotations" method and i removes them, but the map stays centered on the spot and thus when the new annotations come in, it does not move. Is there a way to reset the region and if so, what value do i reset it to. I tried nil, zero and some calculated value but "core animation" says they are all invalid. how do i get that to zoom out and back in on my new annotations? here is some code -(void)recenterMap { NSArray *coordinates = [_mapView valueForKeyPath:@"annotations.coordinate"]; CLLocationCoordinate2D maxCoord = {-90.0f, -180.0f}; CLLocationCoordinate2D minCoord = {90.0f, 180.0f}; //NSLog(@"%@", [coordinates description]); for (NSValue *value in coordinates) { CLLocationCoordinate2D coord = {0.0f, 0.0f}; [value getValue: &coord]; if(coord.longitude > maxCoord.longitude) { maxCoord.longitude = coord.longitude; } if(coord.latitude > maxCoord.latitude){ maxCoord.latitude = coord.latitude; } if(coord.longitude < minCoord.longitude){ minCoord.longitude = coord.longitude; } if(coord.latitude < minCoord.latitude){ minCoord.latitude = coord.latitude; } } MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}}; region.center.longitude = (minCoord.longitude + maxCoord.longitude) / 2.0; region.center.latitude = (minCoord.latitude + maxCoord.latitude) / 2.0; region.span.longitudeDelta = maxCoord.longitude - minCoord.longitude; region.span.latitudeDelta = maxCoord.latitude - minCoord.latitude; [_mapView setRegion: region animated: YES]; } Thats the recenter methos i'm using - (MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id <MKAnnotation>)annotation{ MKAnnotationView *view = nil; if(annotation != mapView.userLocation){ Annotation *schoolAnn = (Annotation*)annotation; view = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"schoolLoc"]; if(nil == view){ view = [[[MKPinAnnotationView alloc] initWithAnnotation:schoolAnn reuseIdentifier:@"schoolLoc"]autorelease]; } [(MKPinAnnotationView *)view setAnimatesDrop:YES]; [view setCanShowCallout:YES]; } else { [self recenterMap]; } return view; } This "else" piece waits until the blue marble drops in then recenters the map. The problem i have with that part is that when i go back to the previous View Controller i remove all annotations, so when i come back in the User location (for some reason) does not pop back in. How do i get this to pop back in? thanks in advance guys

    Read the article

  • use pin.title in other class

    - by Marco
    Hello i have implemented the following code: - (void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annView calloutAccessoryControlTapped:(UIControl *)control { name = annView.annotation.title; NSLog(name, [annView description]); } and how can I use the variable name in another class? can you please help me, i am new in iphone developing!

    Read the article

  • How do I zoom an MKMapView to the users current location without CLLocationManager?

    - by Danny Tuppeny
    With the MKMapView there's an option called "Show users current location" which will automatically show a users location on the map. I'd like to zoom into this location without adding a CLLocationManager (this seems silly if the map is already taking care of this). The problem is, I can't find a nice event that fires when the map has figured out the users location, so I don't know where to put the code that will zoom/scroll. I tried using the viewForAnnotation method like this: - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation class] == [MKUserLocation class] ) { NSLog(@"UserLocation annotation"); return [map viewForAnnotation:annotation]; } return nil; } However it doesn't fire if the users location is off the screen. Is there a way to be notified when an MKMapView has got the user location so I can zoom in to it, or do I just have to add a CLLocationManager for this?

    Read the article

  • Custom annotationView images revert to pins when clicked

    - by Danny Tuppeny
    I'm displaying custom images on a map (instead of the default pins) using the code below. However, when I tap on an item (and the callout appears), the image reverts to the default red pin. How can I keep my custom image, even when the callout is displayed? - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinAnnotation = nil; if (annotation != mapView.userLocation) { static NSString *pinID = @"mapPin"; pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID]; if (pinAnnotation == nil) pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease]; // Set the image pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"]; // Set ability to show callout pinAnnotation.canShowCallout = YES; // Set up the disclosure button on the right side UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinAnnotation.rightCalloutAccessoryView = infoButton; [pinID release]; } return pinAnnotation; [pinAnnotation release]; }

    Read the article

  • How to tell a rightCalloutAccessoryView has been touched for MapKit

    - by iamdadude
    I have a MKAnnotationView being allocated with a DetailDisclosure button being displayed on the right side of the annotation. How would I go about knowing when a user clicked on the annotation button? This is what my code looks like right now - UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinView.rightCalloutAccessoryView = rightButton; pinView.animatesDrop = YES; Is there a built in method to detect when a accessory view has been touched? I'm guessing it would be like the UITableView methods, but I can't find anything. Thanks for any help.

    Read the article

  • Toubleshooting mapkit performance

    - by brettr
    I'm plotting over 500 points on a map using mapkit. Zooming is a little jittery compared to the native google map app. I've discovered what is causing the slowness. I'm adding custom annotations so that I can later add different pin colors and buttons for detail views: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(AddressNote *) annotation { MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentlocation"]; annView.pinColor = MKPinAnnotationColorGreen; annView.animatesDrop=TRUE; annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5); return annView; } If I comment out the above code, everything works fine. Very smooth with zooming in/out. Should I be adding annotations differently to boost performance?

    Read the article

  • iPhone Map: Identifying Users Location

    - by senfo
    I have a number of annotations on my map, in addition to the users current location. This works fine, except the default color for the users current location is the same as all of the other annotations. I'd like to make the pin green for the users current location so that it's uniquely identifiable from the other pins. How do I do this? Bellow is the method I've been using (I can't find a way to determine which annotation is the users current location): - (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *identifier = @"Pin"; MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (pinView == nil) { pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease]; pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinView.animatesDrop = YES; pinView.canShowCallout = YES; } else { pinView.annotation = annotation; } return pinView; }

    Read the article

  • My map callouts don't display the image when clicked

    - by Neelam Khan
    I am developing an iPhone application for a university project and I'm new to iPhone development. I have looked through Apple's MapCallouts code but it doesn't seem feasible to implement it. So far my code displays a map, drops annotations, displays the title and it displays the right call out button. But this is where I encounter problems. When I press on the callout button, it displays a blank view controller but it should display a different image for every callout that's tapped and this isn't happening so far. I have added my code below: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { //NSUInteger tag = ((UIButton *)control).tag; if (self.detailController==nil) { DetailViewController* detailViewController = [[DetailViewController alloc] init]; [self.navigationController pushViewController:detailViewController animated:YES]; } // self.detailController.tag =1; //to identify image required // self.detailController.tag = tag; [self.navigationController pushViewController:detailController animated:YES]; }

    Read the article

  • Customize Annotation problem....Plz Help.. !!

    - by user128647
    I want to show my custom UIView(.Xib View) to appear when user tabbed on pins (not apple's callOutBubble) and in that UIView there should be a button which fires an IBAction on touched down event. Therefore i have added an AddObserver method to MKAnnotationView. which responds to touch events over pin in MKMapView. But i have also added 3 buttons over that XIB view, which have also assined IBActions. But when i run application, Buttons in Customized Annotation view are not responding to IBAction (Touch Down)? Why this happens ?? What is the solution for that??? I need to have called some method, when those 3 buttons tabbed. Thanks

    Read the article

  • preventing selection on MKPointAnnotation

    - by Derek
    Is there a way to prevent an annotation in a MKMapView instance from being enabled. In other words, when the user taps the red pin on the map, is there a way to prevent it from highlighting the pin. Right now the pin turns dark when touched... Edit: I'm using the following code to return the MKPinAnnotationView // To future MKMapView users - Don't forget to set _mapView's delegate _mapView.delegate = self; _annotation = [[MKPointAnnotation alloc] init]; _annotation.coordinate = myLocation; [_mapView addAnnotation:_annotation]; -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:@"id"]; pin.enabled = NO; return pin; }

    Read the article

  • Display selectedAnnotation info

    - by elife_iPhone
    When I use this: - (void)mapView:(MKMapView *)myMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { NSLog(@"SelectedAnnotations is %@", myMapView.selectedAnnotations); } It Displays this in the log. "<Annotation: 0x586cdb0>" Now this is a weird question, but how do I get the info from this Annotation? I have lost my mind. This is what is in the annotation. myAnnotation = [[Annotation alloc] init]; myAnnotation.dealName=[NSString stringWithFormat:@"%@",[tempValue objectForKey:@"name"]]; myAnnotation.subName=[NSString stringWithFormat:@"Price: $%@",[tempValue objectForKey:@"price"]]; myAnnotation.latitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLatitude"] doubleValue]]; myAnnotation.longitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLongitude"] doubleValue]]; myAnnotation.dealId = [NSNumber numberWithInt:[ [tempValue objectForKey:@"dId"] intValue ]]; Thanks for your help.

    Read the article

  • How to find which annotation send showDetails?

    - by Voloda2
    How to find which annotation send showDetails? MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier] autorelease]; customPinView.pinColor = MKPinAnnotationColorPurple; customPinView.animatesDrop = YES; customPinView.canShowCallout = YES; // add a detail disclosure button to the callout which will open a new view controller page // // note: you can assign a specific call out accessory view, or as MKMapViewDelegate you can implement: // - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control; // UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; customPinView.rightCalloutAccessoryView = rightButton; return customPinView; - (void)showDetails:(id)sender { some code }

    Read the article

  • Not found in protocol

    - by Alex
    I've subclassed MKAnnotation so that i can assign objects to annotations and then assign this object to a view controller like so: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { PlaceDetailView *detailView = [[PlaceDetailView alloc] initWithStyle:UITableViewStyleGrouped]; detailView.place = [view.annotation place]; [self.navigationController pushViewController:detailView animated:YES]; [detailView release]; } This is working great but i'm having the following issues: If i try and access the place getter method like so view.annotation.place i recieve an error: Accessing unknown place getter method If i acces the place getter method like so [view.annotation place] i receive a warning: place not found in protocol From my understanding this is because the place object is not defined in the MKAnnotation protocol, although i'm aware of this i'm not sure how to tell the complier that place does exist and it's not calling it blind.

    Read the article

  • Customized annotation problem

    - by user128647
    I want my custom UIView (.Xib View) to appear when user tabs on pins (not apple's callOutBubble) and in that UIView there should be a button which fires an IBAction on touched down event. Therefore I have added an AddObserver method to MKAnnotationView. which responds to touch events over pin in MKMapView. I have also added 3 buttons over that XIB view, which have also assigned IBActions. But when I run my application, buttons in the customized annotation view are not responding to IBAction (Touch Down). Why does this happen, and how can I fix it? I need to call a method when those 3 buttons are tabbed.

    Read the article

  • Removing and then adding MKAnnotations to a MapView is leaving me with a blank MapView

    - by Chris McCall
    A followup to this quesiton: http://stackoverflow.com/questions/2944581/forcing-reload-of-view-when-returning-from-flipsideview-of-utility-application When returning from the flipside view, I'm calling NSArray *annotations = [NSArray arrayWithArray:[mapView annotations]]; [mapView removeAnnotations:annotations]; To remove all the pins from the map (let me know if this isn't the best way to do this). Then: for(Hole *hole in fetchedObjects) { double latitude = [hole.Latitude doubleValue]; cord.latitude = latitude; double longitude = [hole.Longitude doubleValue]; cord.longitude = longitude; WellPlaceMark *placemark = [[WellPlaceMark alloc] initWithCoordinate:cord withWellType:[NSString stringWithString: hole.WellType]]; [mapView addAnnotation:placemark]; } Plus: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{ MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; if([annotation isKindOfClass:[WellPlaceMark class]]) { ... } annView.animatesDrop=FALSE; return annView; } All of this code seems to be called in the debugger, but when it's finished, I'm presented with a blank map. I've tried zooming out and the pins are nowhere. The map loads up fine on the first try, but once I call removeAnnotations, they never return.

    Read the article

  • MKMapView loading all annotation views at once (including those that are outside the current rect)

    - by jmans
    Has anyone else run into this problem? Here's the code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(WWMapAnnotation *)annotation { // Only return an Annotation view for the placemarks. Ignore for the current location--the iPhone SDK will place a blue ball there. NSLog(@"Request for annotation view"); if ([annotation isKindOfClass:[WWMapAnnotation class]]){ MKPinAnnotationView *browse_map_annot_view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"BrowseMapAnnot"]; if (!browse_map_annot_view) { browse_map_annot_view = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BrowseMapAnnot"] autorelease]; NSLog(@"Creating new annotation view"); } else { NSLog(@"Recycling annotation view"); browse_map_annot_view.annotation = annotation; } ... As soon as the view is displayed, I get 2009-08-05 13:12:03.332 xxx[24308:20b] Request for annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Request for annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view and on and on, for every annotation (~60) I've added. The map (correctly) only displays the two annotations in the current rect. I am setting the region in viewDidLoad: if (center_point.latitude == 0) { center_point.latitude = 35.785098; center_point.longitude = -78.669899; } if (map_span.latitudeDelta == 0) { map_span.latitudeDelta = .001; map_span.longitudeDelta = .001; } map_region.center = center_point; map_region.span = map_span; NSLog(@"Setting initial map center and region"); [browse_map_view setRegion:map_region animated:NO]; The log entry for the region being set is printed to the console before any annotation views are requested. The problem here is that since all of the annotations are being requested at once, [mapView dequeueReusableAnnotationViewWithIdentifier] does nothing, since there are unique MKAnnotationViews for every annotation on the map. This is leading to memory problems for me. One possible issue is that these annotations are clustered in a pretty small space (~1 mile radius). Although the map is zoomed in pretty tight in viewDidLoad (latitude and longitude delta .001), it still loads all of the annotation views at once. Thanks...

    Read the article

  • Problem setText UITextView

    - by Mat
    Hi i have a problem. I have 2 viewcontroller, in the first there is a mapView that implements the function "calloutAccessoryControlTapped" to tap a button on an annotation on the mapView; in the second there is just a UITextView. I want to change the text of the UITextView (and show the SecondViewController) in the second controller once the button on annotation is clicked; here is my code (FirstViewController) Header @interface FirstViewController<MKMapViewDelegate>{ IBOutlet MKMapView *mapView; SecondViewController *secondV;} @end Implementation @implementation FirstViewController - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{ secondV = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; NSString *myS = @"some text here"; [secondV.myTextView setText:myS]; //Switch from this to the secondview [self presentModalViewController:secondV animated:YES]; @end (SecondViewController) Header @interface SecondViewController{ IBOutlet UITextView *myTextView; } @property(nonatomic, retain)UITextView *postitTextView; - (IBAction)backToMAp; - (void)setText:(NSString *)string; @end Implementation @implementation SecondViewController - (IBAction)backToMAp{ //Back To First View; [self dismissModalViewControllerAnimated:YES];} - (void)setText:(NSString *)string{ myTextView.text = string;} In this code when i tap on the button ([self presentModalViewController:secondV animated:YES];) on annotation the first time the second view show up but the text of UITextView don't change, when i back on the FirstView ([self dismissModalViewControllerAnimated:YES];) and then again tap the button to switch again to secondView the text of UITextView change..... Sorry for long thread and for my bad english!! Thank you stack!

    Read the article

  • Can't access annotation property of subclassed uibutton

    - by Tzur Gazit
    I have a mapView to which I add annotations. The pin's callout have a button (rightCalloutAccessoryView). In order to be able to display various information when the button is pushed, i've subclassed uibutton and added a class called "Annotation". @interface CustomButton : UIButton { NSIndexPath *indexPath; Annotation *mAnnotation; } @property (nonatomic, retain) NSIndexPath *indexPath; @property (nonatomic, copy) Annotation *mAnnotation; - (id) setAnnotation2:(Annotation *)annotation; @end Here is "Annotation": @interface Annotation : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString *mPhotoID; NSString *mPhotoUrl; NSString *mPhotoName; NSString *mOwner; NSString *mAddress; } @property (nonatomic, assign) CLLocationCoordinate2D coordinate; @property (nonatomic, copy) NSString *mPhotoID; @property (nonatomic, copy) NSString *mPhotoUrl; @property (nonatomic, copy) NSString *mPhotoName; @property (nonatomic, copy) NSString *mOwner; @property (nonatomic, copy) NSString *mAddress; - (id) initWithCoordinates:(CLLocationCoordinate2D)coordinate; - (id) setPhotoId:(NSString *)id url:(NSString *)url owner:(NSString *)owner address:(NSString *)address andName:(NSString *)name; @end I want to set the annotation property of the uibutton at - (MKAnnotationView *)mapView:(MKMapView *)pMapView viewForAnnotation:(id )annotation, in order to refer to it at the button push handler (-(IBAction) showDetails:(id)sender). The problem is that I can't set the annotation property of the button. I get the following message at run time: 2010-04-27 08:15:11.781 HotLocations[487:207] *** -[UIButton setMAnnotation:]: unrecognized selector sent to instance 0x5063400 2010-04-27 08:15:11.781 HotLocations[487:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIButton setMAnnotation:]: unrecognized selector sent to instance 0x5063400' 2010-04-27 08:15:11.781 HotLocations[487:207] Stack: ( 32080987, 2472563977, 32462907, 32032374, 31884994, 55885, 30695992, 30679095, 30662137, 30514190, 30553882, 30481385, 30479684, 30496027, 30588515, 63333386, 31865536, 31861832, 40171029, 40171226, 2846639 ) I appreciate the help. Tzur.

    Read the article

  • MKMapKit exception when using canShowCallout on annotation view

    - by Kendall Helmstetter Gelner
    I'm trying to use a pretty straightforward custom map annotation view and callout - the annotation view when I create it, just adds a UIImageView as a subview to itself. That works fine. However, when I call canShowCallout on the annotation view, An exception is thrown in MapKit immediately after returning the view. The end of the stack looks like: #0 0x94e964e6 in objc_exception_throw #1 0x01e26404 in -[MKOverlayView _addViewForAnnotation:] #2 0x01e22037 in -[MKOverlayView _addViewsForAnnotations:animated:] #3 0x01e1ddf9 in -[MKOverlayView showAddedAnnotationsAnimated:] #4 0x01df9c0e in -[MKMapView _showAddedAnnotationsAndRouteAnimated:] #5 0x01e0371a in -[MKMapView levelView:didLoadTile:] My viewForAnnotation is pretty simple: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { if ( ! [annotation isKindOfClass:[MyAnnotation class]] ) return nil; MyAnnotationView *useView = (MyAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:@"resuseview"]; if ( useView == nil ) { useView = [[[MyAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"resuseview"] autorelease]; useView.canShowCallout = YES; // if commented out view appears just fine } else { useView.annotation = annotation; } return useView; } As noted in the code, the annotation view works fine as is - until I add canShowCallout, then it crashes the first time the map gets the view.

    Read the article

  • Knowing which annotation is selected and accessing properties of it.

    - by kevin Mendoza
    So far my program can display a database of custom annotation views. Eventually I want my program to be able to display extra information after a button on the annotation bubble is clicked. Each element in the database has a unique entry Number, so I thought it would be a good idea to add this entry number as a property of the custom annotation. The problem I am having is that after the button is clicked and the program switches to a new view I am unable to retrieve the entry number of the annotation I selected. Below is the code that assigns the entry Number property to the annotation: for (id mine in mines) { workingCoordinate.latitude = [[mine latitudeInitial] doubleValue]; workingCoordinate.longitude = [[mine longitudeInitial] doubleValue]; iProspectAnnotation *tempMine = [[iProspectAnnotation alloc] initWithCoordinate:workingCoordinate]; [tempMine setTitle:[mine mineName]]; [tempMine setAnnotationEntryNumber:[mine entryNumber]]; } [mines dealloc]; When the button on an annotation is selected, this is the code that initializes the new view: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { mineInformationController *controller = [[mineInformationController alloc] initWithNibName:@"mineInformationController" bundle:nil]; controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:controller animated:YES]; [controller release]; } and lastly is my attempt at retrieving the entryNumber property from the new view so that I can compare it to the mines database and retrieve more information on the array element. iProspectFresno_LiteAppDelegate *appDelegate = (iProspectFresno_LiteAppDelegate *)[[UIApplication sharedApplication] delegate]; NSMutableArray* mines = [[NSMutableArray alloc] initWithArray:(NSMutableArray *)appDelegate.mines]; for(id mine in mines) { if ([[mine entryNumber] isEqualToNumber: /*the entry Number of the selected annotation*/]) { /* display the information in the mine object */ } } So how do I access this entry number property in this new view controller?

    Read the article

< Previous Page | 1 2 3  | Next Page >