Viewing a Google map, how can I get a starting point or an annotation frame when zooming in on a map?

I set custom annotation output on the map when the annotation is clicked. I get a call for this method.

(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view NS_AVAILABLE(NA, 4_0) 

in this method I want to open a popover, so I want the frame shape (MKAnnotationView *) to look, I get the right frame, and the map in normal mode.

but when I scale the map and click on the annotation, at this time I get the wrong frame at this time, the value of x and y is large, so any solution for any bias or scaling factor I get so that I divide so that I Get the actual annotation frame.

+6
source share
1 answer

Try the following:

 CGPoint annotationPoint = [mapView convertCoordinate:view.annotation.coordinate toPointToView:mapView]; float boxDY = annotationPoint.y - 35; float boxDX = annotationPoint.x - 1; CGRect box = CGRectMake(boxDX, boxDY, 1, 1); [popoverControllerDetail presentPopoverFromRect:box inView:mapView permittedArrowDirections:(UIPopoverArrowDirectionDown| UIPopoverArrowDirectionLeft| UIPopoverArrowDirectionRight) animated:YES]; 
+6
source

Source: https://habr.com/ru/post/903910/


All Articles