当前位置上的图像迅速

所以我在将图像添加到当前位置时遇到问题,我被告知这是不可能的,但我简直无法理解应该是不可能的。

现在,应用程序向地图添加了注释(用户在广告中指定了自己的位置),事实是,我被告知内置位置标记会添加到数组中,然后当您按它时,整个应用程序将崩溃。

到目前为止,解决方案是在您的位置周围添加一个圆圈,问题是当您放大整个屏幕时,您的位置就会被填满,这当然不是解决问题的方法。 / p>

希望有人能够指出正确的方向:)

// ------------------------------------------------
// MARK: - SET CUSTOM PIN
// ------------------------------------------------
func addRadiusCircle(_ location: CLLocation) {
    let circle = MKCircle(center: location.coordinate,radius: 100 as cllocationdistance)
    aMap.addOverlay(circle)
}
func mapView(_ mapView: MKMapView,rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
    if overlay is MKCircle {
        let circle = MKCircleRenderer(overlay: overlay)
        circle.strokeColor = .white
        circle.fillColor = hexValue(hex: "#967bdc")
        circle.lineWidth = 1
        return circle
    }
    return MKOverlayRenderer()
}

// ------------------------------------------------
// MARK: - SET CUSTOM PIN
// ------------------------------------------------
func mapView(_ mapView: MKMapView,viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if annotation.isKind(of: MKPointAnnotation.self) {

        let reuseID = "CustomPinAnnotationView"
        var annotView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseID)

        annotView = MKAnnotationView(annotation: annotation,reuseIdentifier: reuseID)
        annotView!.canShowCallout = false

        // Custom Pin image
        let subtitleStr = annotation.subtitle!
        let splitArr = subtitleStr!.components(separatedBy: "--")
        let pinName = splitArr[0]


        // print("PINNAME: \(pinName)")
        let imageView = UIImageView(frame: CGRect(x:0,y:0,width: 40,height: 40))
        imageView.image =  UIImage(named: pinName)

        imageView.center = annotView!.center

        imageView.contentMode = .scaleAspectFill
        annotView!.addSubview(imageView)
        annotView?.centerOffset = CGPoint(x: 0,y: -(40 / 2))
    return annotView
    }
return nil
}
luyan8883 回答:当前位置上的图像迅速

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3156698.html

大家都在问