如何将具有一定半径的圆添加到我的MKpointAnnotation IOS Swift中

时间:2015-09-24 23:24:24

标签: ios swift mapkit

有人能指出我正确的方向,为我的观点增加一个半径。它非常标准的代码,我尝试添加一个MKcircle,但这对我的地图没有任何意义。

类ViewController:UIViewController,MKMapViewDelegate,CLLocationManagerDelegate {

@IBOutlet weak var maps: MKMapView!
var locationManager = CLLocationManager()

override func viewDidLoad() {
    super.viewDidLoad()




    var latitude:CLLocationDegrees = 54.53
    var longitude:CLLocationDegrees = -6.055
    var latDelta:CLLocationDegrees = 0.015 //difference of lats from one side of screen to another
    var longDelta:CLLocationDegrees = 0.015 //difference of lats from one side of screen to another

    var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)

    var location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude,longitude)

    var region:MKCoordinateRegion = MKCoordinateRegionMake(location, span)
    var lenght:CLLocationDistance = 2


    var point = MKPointAnnotation()
    self.maps.delegate = self
    point.title = "Home"
    point.subtitle = "time for home"
    point.coordinate = location



    maps.addAnnotation(point)
    maps.selectAnnotation(point, animated: true)
    var cir:MKCircle = MKCircle(centerCoordinate: location, radius: length) //added this but nothing is displayed on map

    maps.addOverlay(cir)



    maps.setRegion(MKCoordinateRegionMake(point.coordinate, MKCoordinateSpanMake(latDelta,longDelta)), animated: true)
    // Do any additional setup after loading the view, typically from a nib.


}



func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {

    if (annotation.isKindOfClass(MKUserLocation)){
        return nil
    }
    var myPin = mapView.dequeueReusableAnnotationViewWithIdentifier("MyIdentifier") as? MKPinAnnotationView
    if myPin != nil {
        return myPin
    }

    myPin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "MyIdentifier")
    myPin?.pinColor = .Green
    return myPin
}

1 个答案:

答案 0 :(得分:1)

实施duplicate symbol _OBJC_IVAR_$_SDWebImageDownloaderOperation.orientation in: /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-AD8E43D0E4994A5B.o /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-4D62FB959721E071.o duplicate symbol _OBJC_IVAR_$_SDWebImageDownloaderOperation._credential in: /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-AD8E43D0E4994A5B.o /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-4D62FB959721E071.o duplicate symbol _OBJC_IVAR_$_SDWebImageDownloaderOperation._imageData in: /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-AD8E43D0E4994A5B.o /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-4D62FB959721E071.o duplicate symbol _OBJC_IVAR_$_SDWebImageDownloaderOperation._connection in: /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/CloseBuy.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-AD8E43D0E4994A5B.o /Users/Daddio/Library/Developer/Xcode/DerivedData/MYAPPNAME-fpqubbtwwhfsgegevxpimtzqzhqb/Build/Intermediates/MYAPPNAME.build/Debug-iphoneos/MYAPPNAME.build/Objects-normal/arm64/SDWebImageDownloaderOperation-4D62FB959721E071.o 委托:

rendererForOverlay

enter image description here