Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle GMSCircle #32

Closed
MarvinNazari opened this issue Nov 20, 2017 · 4 comments
Closed

How to handle GMSCircle #32

MarvinNazari opened this issue Nov 20, 2017 · 4 comments

Comments

@MarvinNazari
Copy link

HI, awesome framework, really easy to handle clustering, I'm interested to know if u have some suggestion how u would handle adding circles for the pin, in my case is basically accuracy circle which I use GMSCircle to show that. But with cluster GMSMapViewDataSource there is no way to add the circle, I wonder if u know any workaround for any delegates call that I can use to add the circles my self, I only want to add the circles when the pins are unclustred.

Thanks.

@maxep
Copy link
Contributor

maxep commented Nov 20, 2017

Hi @MarvinNazari
I guess the datasource method should ask fo an overlay instead of a marker. As a workaround, you can create a circle view and set it as the marker's iconView.

@MarvinNazari
Copy link
Author

@maxep: I already have a pin with custom view which I use iconView for, shouldn't circle be it's own overlay?

@maxep
Copy link
Contributor

maxep commented Nov 20, 2017

Not sure to understand what you mean by it's own overlay.
I've just checked and it's actually not possible to animate a GMSOverlay subclass other than a GMSMarker. So you cannot use a GMSCircle as a cluster or an annotation representation.

@MarvinNazari
Copy link
Author

This is my use case, and i have already a pretty complicated custom view which i use for GMSMarker.iconView

class ViewController: UIViewController {

    lazy var mapView: GMSMapView = {
        let view = GMSMapView()
        return view
    }()
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        mapView.frame = view.bounds
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        [
            MapPinViewModel(coordinate: CLLocationCoordinate2D(latitude: 40.7589, longitude: -73.9851), accuracyRadius: 500)
        ].forEach { pin in
            pin.show(in: mapView)
        }
        
    }

}

struct MapPinViewModel {

    let coordinate: CLLocationCoordinate2D
    let accuracyRadius: Double
    
    func show(in mapView: GMSMapView) {
        mapMarker.map = mapView
        accuracyCircle.map = mapView
    }
    
    var mapMarker: GMSMarker {
        return GMSMarker(position: coordinate)
    }
    
    var accuracyCircle: GMSCircle {
        return GMSCircle(position: coordinate, radius: accuracyRadius)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants