решение:
в CustomCalloutView
var annotationPoint: CGPoint
required init(annotation: CustomAnnotation, annotationPoint: CGPoint) {
self.representedObject = annotation
self.annotationPoint = annotationPoint
}
func presentCallout(from rect: CGRect, in view: UIView, constrainedTo constrainedRect: CGRect, animated: Bool) {
self.center = annotationPoint.applying(CGAffineTransform(translationX: 0, y: -self.frame.height - 40.0))
view.addSubview(self)
}
в MapVC
:
func mapView(_ mapView: MGLMapView, calloutViewFor annotation: MGLAnnotation) -> MGLCalloutView? {
let customAnnotation = CustomAnnotation(coordinate: annotation.coordinate, title: title, subtitle: subtitle, image: img!)
let annotationPoint = mapView.convert(annotation.coordinate, toPointTo: nil)
return CustomCalloutView(annotation: customAnnotation, annotationPoint: annotationPoint)
}