单击按钮时显示叠加

时间:2017-05-31 13:42:18

标签: swift button mapkit overlay

我是新开发者。我希望通过按钮跟踪用户移动,例如当点击按钮MapKit显示叠加或用户移动时。 我有这段代码:

var mapOverlay: MKTileOverlay!
 func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        if overlay is MKPolyline {
            let polylineRenderer = MKPolylineRenderer(overlay: overlay)
            polylineRenderer.strokeColor = UIColor.red
            polylineRenderer.lineWidth = 3
            return polylineRenderer
        }
        return MKOverlayRenderer()
    }
    @IBAction func start(_ sender: Any) { 
   let annotation = MKPointAnnotation()
            annotation.coordinate = mapView.userLocation.coordinate
            annotation.subtitle = "Start"
            self.mapView.addAnnotation(annotation)
}

0 个答案:

没有答案