Created
January 9, 2019 04:13
-
-
Save ysam12345/2a8087311706e42c9f9422fee8415443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addPointAndCircleToMapView( lat: Double, lon: Double, radius: Int, content: String) { | |
let newPin = MKPointAnnotation() | |
let coordinate = CLLocationCoordinate2D(latitude: lat,longitude: lon) | |
newPin.coordinate = coordinate | |
newPin.title = content | |
let circle = MKCircle(center: coordinate, radius: CLLocationDistance(radius)) | |
mapView.add(circle) | |
mapView.addAnnotation(newPin) | |
} | |
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { | |
guard overlay is MKCircle else { return MKOverlayRenderer() } | |
let circle = MKCircleRenderer(overlay: overlay) | |
circle.strokeColor = UIColor.red | |
circle.fillColor = UIColor(red: 255, green: 0, blue: 0, alpha: 0.1) | |
circle.lineWidth = 1 | |
return circle | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment