The call pops up for other contacts

I am working on a map with over 5000 pins. Every time I change the region, I add or remove annotationViews based on how much I scaled.

The only problem is this (extreme test):

Callout being eaten alive

When there is a little more space between the pins, the leader moves back and forth, but often the red pins go to the end.
I am only using the basic MKPinAnnotationView. No customizable leaders. I tried to implement Aaron's Z-ordering category MKAnnotationViews Z-ordering but didn't seem to help.

EDIT:

I haven't decided yet, but I have some thoughts.

MapKit is poorly written. The MapView is responsible for viewing the views, so at least the selected one stays on top.

Maybe too many annotations to handle mapView.

HOW TO APPLY

just add 5000 annotations.

-(void)addAnnotations
{
   NSMutableArray *annotations = [NSMutableArray array];

   for(int i=0;i<5000;i++) {
       CGFloat latDelta = rand()*0.125/RAND_MAX - 0.02;
       CGFloat lonDelta = rand()*0.130/RAND_MAX - 0.08;

       CGFloat lat = 59.189358;
       CGFloat lng = 18.267839;

       CLLocationCoordinate2D newCoord = {lat+latDelta, lng+lonDelta};

       DTSAnnotation *annotation = [DTSAnnotation annotationWithCoord:newCoord];

       [annotation setTitle:@"."];

       [annotations addObject:annotation];
   }
   [[self mapView]addAnnotations:annotations];
}

      

+3


source to share


1 answer


You can fix this by setting the zPosition for the view in the didSelect and didDselect map delegate methods:



public func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!)
    {
        view.layer.zPosition = 0
    }

    public func mapView(mapView: MKMapView!, didDeselectAnnotationView view: MKAnnotationView!)
    {
        view.layer.zPosition = -1
    }

      

+3


source







All Articles