Annotation details after detail disclosure pressed?
You might have an easier time using the MKMapViewDelegate mapView:annotationView:calloutAccessoryControlTapped: method, which tells you directly which annotation view was tapped.
You might have an easier time using the MKMapViewDelegate mapView:annotationView:calloutAccessoryControlTapped: method, which tells you directly which annotation view was tapped.
The code in the accepted answer fires when the region is changed for any reason. To properly detect a map drag you have to add a UIPanGestureRecognizer. Btw, this is the drag gesture recognizer (panning = dragging). Step 1: Add the gesture recognizer in viewDidLoad: -(void) viewDidLoad { [super viewDidLoad]; UIPanGestureRecognizer* panRec = [[UIPanGestureRecognizer alloc] … Read more
plz use this – (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; if ([annotation isKindOfClass:[CustomAnnotation class]]) { CustomAnnotation *customAnnotation = (CustomAnnotation *) annotation; MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@”CustomAnnotation”]; if (annotationView == nil) annotationView = customAnnotation.annotationView; else annotationView.annotation = annotation; //Adding multiline subtitle code UILabel *subTitlelbl = [[UILabel alloc]init]; subTitlelbl.text = @”sri … Read more
Try a custom overlay. Add this in viewDidLoad: MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000]; [map addOverlay:circle]; userLocation can be obtained by storing the MKUserLocationAnnotation as a property. Then, to actually draw the circle, put this in the map view’s delegate: – (MKOverlayRenderer *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay { MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay]; circleView.strokeColor = … Read more
When you call addAnnotation or addAnnotations, the map view adds the reference(s) to its internal list of annotations. The annotations property of MKMapView simply returns this internal list (whatever type it might be) as an NSArray. I don’t know of any place in the documentation where it states that the annotations property returns the array … Read more
If you just want to freeze the map view at the overlay, you could set the map view’s region to the overlay’s bounds and set scrollEnabled and zoomEnabled to NO. But that won’t let the user scroll or zoom inside the overlay’s bounds. There aren’t built-in ways to restrict the map view to the overlay’s … Read more
Based on psoft‘s excellent information, I was able to achieve what I was looking for with this code. NSString *location = @”some address, state, and zip”; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location completionHandler:^(NSArray* placemarks, NSError* error){ if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] … Read more
Okay I officially answered my own question but since I didn’t find it anywhere before I’ll post the answer here: //To calculate the search bounds… //First we need to calculate the corners of the map so we get the points CGPoint nePoint = CGPointMake(self.mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y); CGPoint swPoint = CGPointMake((self.mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height)); //Then … Read more
This maybe the easiest method. It uses apple servers for geocoding. Sometimes the apple servers provide better response than google. And soon (in IOS 6.1) the google maps will be completely out of IOS. So it is good if the app stays inside the apples provided features. -(void)searchBarSearchButtonClicked:(UISearchBar *)theSearchBar { [theSearchBar resignFirstResponder]; CLGeocoder *geocoder = … Read more
Note that there is a method on MKMapView (not MKAnnotationView) for selecting an annotation programmatically that works more or less as you would expect: – (void)selectAnnotation:(id < MKAnnotation >)annotation animated:(BOOL)animated However, it automatically deselects any currently annotation at the same time so this doesn’t solve your problem. Oddly, there is a property on MKMapView that … Read more