CFRJ
CFRJ

Reputation: 157

How to resize mapOverlay with handle on the edge of the overlay?

so like the title says, I would like to know how to implement the black handle/button there is on the edge of the overlay

what I want to accomplice

Code I user for creating my overlay and annotation currently

func makeAnnotation(locationCoordinate: CLLocationCoordinate2D){
    let overlay = MKCircle(center: locationCoordinate, radius: 100)
    let allOverlays = self.mapView.overlays
    let annotation = MKPointAnnotation()
    let allAnnotations = self.mapView.annotations
    if self.mapView.annotations.isEmpty == false {

        self.mapView.removeAnnotations(allAnnotations)
        self.mapView.removeOverlays(allOverlays)
    }

    //Make coordinats into adress
    let location = CLLocation(latitude: locationCoordinate.latitude, longitude: locationCoordinate.longitude)
    CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
        if error != nil {
            print(error as Any)
        }
        let placemark = placemarks?[0]
        guard let street = placemark?.thoroughfare else {
            return annotation.title = ""
        }
        guard let addressNumber = placemark?.subThoroughfare else {
            return annotation.title = street

        }
        self.fullAdress = street + " " + addressNumber
        annotation.title = self.fullAdress

    })
    annotation.coordinate = locationCoordinate
    mapView.add(overlay)
    mapView.addAnnotation(annotation)
}

How it looks

my current result

Upvotes: 1

Views: 382

Answers (1)

Carlos Correia
Carlos Correia

Reputation: 43

I've just created this Pod based on ResizableMKCircleOverlay.

I had to subclass MKMapView to get a good layer of abstraction. It's actually pretty easy to integrate with your current MapViewController If you already have one with simple functionality.

Here.

Upvotes: 0

Related Questions