我一直在寻找如何使用Swift 2.0为MapView制作MKCircle注释的一个很好的解释,但我似乎找不到充分的解释.有人可以发布一些示例代码来展示如何创建MKCircle注释吗?这是我用来制作地图并获得坐标的代码.
let address = self.location
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(address, completionHandler: {(placemarks, error) -> Void in
if((error) != nil){
print("Error", error)
}
if let placemark = placemarks?.first {
let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate
self.locationCoordinates = coordinates
let span = MKCoordinateSpanMake(0.005, 0.005)
let region = MKCoordinateRegion(center: self.locationCoordinates, span: span)
self.CIMap.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.coordinate = self.locationCoordinates
self.CIMap.addAnnotation(annotation)
self.CIMap.layer.cornerRadius = 10.0
self.CIMap.addOverlay(MKCircle(centerCoordinate: self.locationCoordinates, radius: 1000))
}
})
Run Code Online (Sandbox Code Playgroud)