MapView 用户的当前位置常规 Pin

MapView User's Current Location Regular Pin

我无法将 "regular" 图钉置于用户的当前位置。我四处搜寻但找不到太多。现在,在用户的当前位置,我只有位置信标。如何将其更改为常规 "pin"?我尝试了 nnotationView?.annotation = annotation 但这似乎不起作用。

extension ViewController: MKMapViewDelegate {

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

        var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "AnnotationView")

        if annotationView == nil {
            annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "AnnotationView")
        }

        if let title = annotation.title, title == "Park Test" {

            annotationView?.image = UIImage(named: "Park icon test")

        } 

   else if annotation === mapView.userLocation {

            return nil
        }

        annotationView?.canShowCallout = true

        return annotationView

    }

我的代码使用注释。

  func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?  {

    let identifier = "MyCustomAnnotation"

    if annotation is MKUserLocation { return nil }
    var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKPinAnnotationView

    if annotationView == nil {
        annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
        annotationView?.canShowCallout = true
        annotationView?.isEnabled = true
        annotationView?.isDraggable = true
        let btn = UIButton(type: .detailDisclosure)
        annotationView?.rightCalloutAccessoryView = btn
    } else {
        annotationView?.annotation = annotation
    }
    return annotationView
}

通过添加此代码来调用委托。

 var point = MKPointAnnotation()
 self.point.coordinate = location.coordinate
 self.point.title = ("Your title")
 self.point.subtitle = (" your subs")
 self.mapView.addAnnotation(self.point)
 //selects the annotation
 self.mapView.selectAnnotation(self.point, animated: true)