Draw a circle of 1000m radius around users location in MKMapView

前端 未结 8 2039
死守一世寂寞
死守一世寂寞 2020-11-29 17:18

(Using iOS 5 and Xcode 4.2)

I have an MKMapView and want to draw a circle of 1000m radius around the user location.

On the surface it would seem tha

8条回答
  •  情话喂你
    2020-11-29 18:11

    All I did is, After displaying the location on the map kit called the below function in the end.

    @IBOutlet weak var mapView: GMSMapView!
    
    var cirlce: GMSCircle!
    
    override func viewDidLoad() {
    
        super.viewDidLoad()
        mapView.delegate = self
        circleview(redius: 5000) 
    
      }
    
    //used this func to draw the circle
    
     func circleview(redius:Double) {
    
        let  circleCenter = CLLocationCoordinate2D(latitude: 13.3450223, longitude: 74.7512519)
    
        cirlce = GMSCircle(position: circleCenter, radius: redius)
        cirlce.fillColor = UIColor(red: 230.0/255.0, green: 230.0/255.0, blue: 250.0/255.0, alpha:1.0)
        cirlce.strokeColor = .blue
        cirlce.strokeWidth = 2
        cirlce.map = mapView
      }
    

提交回复
热议问题