Skip to content

Instantly share code, notes, and snippets.

@ysam12345
Created January 9, 2019 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysam12345/2a8087311706e42c9f9422fee8415443 to your computer and use it in GitHub Desktop.
Save ysam12345/2a8087311706e42c9f9422fee8415443 to your computer and use it in GitHub Desktop.
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