map annotation with image

Discussion in 'iOS Programming' started by jagatnibas, Nov 14, 2011.

  1. jagatnibas macrumors regular

    Jul 28, 2008
    i need to see a good example of annotaion with image and detail disclosure.

    secondly, i added text based annotaions around 500 of them, but i saw the map zooming erratically and sometimes not staying at particular annotation and hopping around annotations, is it a bug or there are better ways to handle this ?

  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    500 is a bit much.. are you sure there isn't a better way? to add a segment, to only show special categorys, or within range, or something?
    And if u checked documentation, you'd see there is a delegate method to define your own pins..

    -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
    	MKAnnotationView *pinView = nil; 
            // try to dequeue an existing pin view first
            static NSString* CustomerAnnotationIdentifier = @"CustomId";
            MKAnnotationView* pinView = (MKAnnotationView *)
    		[mapView dequeueReusableAnnotationViewWithIdentifier:CustomerAnnotationIdentifier];
            if (!pinView)
                // if an existing pin view was not available, create one
                MKAnnotationView* customPinView = [[[MKAnnotationView alloc]
    												initWithAnnotation:annotation reuseIdentifier:CustomerAnnotationIdentifier] autorelease];
    			UIImage *pinImage = [UIImage imageNamed:@"intervention.png"];
    			customPinView.image = pinImage;
    			UIImageView *drIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intervention.png"]];
                customPinView.leftCalloutAccessoryView = drIconView;
                [drIconView release];
                customPinView.canShowCallout = YES;
                return customPinView;
                pinView.annotation = annotation;
            return pinView;
    Not sure if it's the best way to go, but it works for me :)

Share This Page