如何更改MGLUserLocationAnnotationView的zPosition层

时间:2018-07-04 06:48:16

标签: mapbox swift4.1

如何更改MGLUserLocationAnnotationView的zPosition层

我想将蓝点移到注释下方。请提出建议。

我也从这里尝试过:https://www.mapbox.com/ios-sdk/examples/user-location-annotation/

func mapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? {

    if annotation is MGLUserLocation && mapView.userLocation != nil {
        let userLocationAnnotationView = CustomUserLocationAnnotationView()
        userLocationAnnotationView.layer.zPosition = 90
        return userLocationAnnotationView
    }

    guard let annotation = annotation as? SpotAnnotation else {
        return nil
    }

    if let annotationType = annotation.annotationType {

        // For better performance, always try to reuse existing annotations.
        var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "\(annotationType.hashValue)")

        // If there’s no reusable annotation view available, initialize a new one.
        if annotationView == nil {

            annotationView = annotation.spotProfileAnnotationWith(annotation.spot.profileImage, annotation.spot.limitedTimeType)
            annotationView?.layer.zPosition = 100
        } else {
            annotationView?.annotation = annotation
        }
        return annotationView
    }
    return nil
}

我已将自定义注释的图层zPosition设置为100。但是,在自定义注释顶部仍显示蓝点。

0 个答案:

没有答案