I added MKAnnotation to my MapView using the following code.
flag * flag = [[flaglock] init]; Flag.title = @ "Golf Course"; Flag.subtitle = @ "Green"; Flag.coordinate = CLLocationCoordinate2DMake (28.457394,77.108667); [Add mapView signal: flag]; Installing the image like and
- (MKAnnotationView *) MapView: (MKMapView *) mV viewForAnnotation: (id's & lt; MKAnnotation & gt;) Annotation {if (([Annotation iskind of class: [flag class]])) {mk pinnotation veve * pinview = zero; If (annotation! = MapView.userLocation) {static NSString * defaultPinID = @ "PinId1"; Pinview = (MKPinNnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: defaultPinID]; If (pinView == zero) pinView = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @ "pin1"] autorelease]; // pinviewview [[Mk annotation weave] Init with annotation: Annotation riage identifier: @ "pin1"]; PinView.canShowCallout = Yes; PinView.draggable = Yes; [Pinview set image: [UIImage imageNamed: @ "flag2.png"]]; } And {{mapView.userLocation set title: @ "I am here"]; }} Return pinview; } But the image for MKAnnation is not found. What is wrong? Please help me
I have only one problem. Now using the working version below
- (MKAnnotationView *) MapView: (MKMapView *) theMapView viewForAnnotation: (ID of & lt; MKAnnotation & gt;) Annotation {if ( [Annotation isKindOfClass: [MKUserLocation class]]) Return zero; If ([encashment iskind of class: [annotation class]]) {static nssting * sfn annotation identifier = '' sfn annotation identifier ''; MKPinAnnotationView * pinView = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: SFAnnotationIdentifier]; If (pinView!) {MKAnnotationView * annotationView = [[[MKAnnotationView alloc] initWithAnnotation: Annotation reuseIdentifier: SFAnnotationIdentifier] autorelease]; Annotation View.canShowCallout = Yes; UIImage * flagImage = [UIImage image named: @ "map_pin.png"]; CGRTT Resize; ResizeRect.size = flagImage.size; CGSize maxSize = CGRectInset (self.view.bounds, 10.5, 10.5). Shape; MaxSize.height - = self Navigation Controller Navigation Bar.frame.height.height + 40.0; If (resizeRect.size.width> maxSize.width) resizeRect.size = CGSizeMake (maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width); If (resizeRect.size.height> gt; maxSize.height) resizeRect.size = CGSizeMake (resizeRect.size.width / resizeRec.size.height * maxSize.height, maxSize.height); ResizeRect.origin = (CG point) {0.0F, 0.0F}; UIGraphicsBeginImageContext (resizeRect.size); [Flag image drawrectact: resize]; UIImage * resizedImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext (); Annotation View.image = resizedImage; Annotation View.opaque = NO; UIButton * rightButton = [system with UIButton Button: UIButtonTypeDetailDisclosure]; Comment * AnnotationObject = (Annotation *) Annotation; RightButton.tag = annoterObject.annoteCount; [Right button addTarget: auto-action: @selector (for ShowDetailsControlEvents: UIControlEventTouchUpInside;); Annotation View.rightCalloutAccessoryView = rightButton; Return Annotation View;} and {pinView.annotation = annotation;} Return pinView;} Return zero;} This is a work code.
Comments
Post a Comment