Norway


I want to show a VC as a pop up when the user taps on one of the markers on the .

The reason that I want to do this is because I want to control the view that pops up when the is tapped. I tried using the mapView(mapView: GMSMapView, markerInfoWindow marker: GMSMarker) delegate method. But I don’t know how to create a view controller in that method that controls the marker info window’s view.

To present a VC as a pop over, I did this:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("MarkerInfoController")
vc.modalInPopover = true
vc.modalPresentationStyle = .Popover
print(marker.iconView)
vc.popoverPresentationController!.sourceView = marker.iconView

self.presentVC(vc) // this is from EZSwiftExtensions. Don't worry about it

The problem arises when I try to set the sourceView of the UIPopoverPresentationController. I thought using the iconView property would work, but no. There is always an error saying that sourceView is not set.

How can I get the for the marker, so that I can assign it to sourceView?

P.S. This is how a marker is created:

func mapView(mapView: GMSMapView, didLongPressAtCoordinate coordinate: CLLocationCoordinate2D) {
    let marker = GMSMarker(position: coordinate)
    marker.map = mapView
}



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here