0

Hello I would like to add a dynamic display with a number in my point.

As in the picture, I already have the icons on the map.

Adding the numbers in point?

enter image description here

leedream
  • 559
  • 1
  • 6
  • 21

1 Answers1

0

There's a method to define what the annotation view looks like:

-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id<MKAnnotation>)annotation 
{
    MKPinAnnotationView *pinView = nil; 
    if(annotation != mapView.userLocation) 
    {
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinID"];

        if ( pinView == nil ) 
        {
            pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation 
                                                      reuseIdentifier:defaultPinID];
        }

        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;

        . . .

        // -----------------------------------
        // Add extra subviews here
        // -----------------------------------
        UILabel *lblNumbers = [[UILabel alloc] init...];

        lblNumbers.text = ....;
        lblNumbers.backgroundColor = [UIColor colorWithRed:0.1 Green:0.1 Blue:0.1];

        // add the subview to the pinView
        [pinView addSubview:lblNumbers];
    } 

    return pinView;
}
Zhang
  • 11,549
  • 7
  • 57
  • 87