前提・実現したいこと
MKMarkerAnnotationViewを常に表示するようにしたいです。
デフォルトの設定ではAnnotationが密集しているところは
重ならないように消えたり表示されたりしますが、これを常に表示させる状態にしたいです。
発生している問題・エラーメッセージ
こちらの記事を参考にさせて頂きAnnotation生成時に
displayPriorityにrequiredを設定しているのですが、mapviewを動かしたり拡大縮小すると消えてしまいます
該当のソースコード
Swift
1func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{ 2 if annotation is MKUserLocation{ 3 return nil 4 } 5 6 let id = "marker" 7 var markerView = mapView.dequeueReusableAnnotationView(withIdentifier: id) as? MKMarkerAnnotationView 8 9 if markerView == nil{ 10 markerView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: id) 11 markerView?.canShowCallout = true 12 markerView?.rightCalloutAccessoryView = UIButton(type: .infoDark) 13 markerView?.animatesWhenAdded = true 14 markerView?.displayPriority = .required 15 }else{ 16 markerView?.annotation = annotation 17 } 18 19 return markerView 20 }
試したこと
Annotation生成時にdisplayPriorityにrequiredを設定した
あなたの回答
tips
プレビュー