1
votes

I am using the Google Maps SDK for iOS to create a custom marker info window. The default (first image) renders the anchor right above the marker.

I created a custom view with a freeform xib of 150x150 pts and loaded it into the delegate:

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView?

How would I make that same effect as the default render and if possible create that shadow effect under the label as well?

Is this built into the SDK?

enter image description here [enter image description here]

1

1 Answers

1
votes

You can set your infoWinwod anchor like this: marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.4) and you can do it inside

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
        let infoWindow = Bundle.main.loadNibNamed("CustomInfoWindow", owner: self.view, options: nil)!.first! as! CustomInfoView
        marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.4)
        return infoWindow
    }

Theoretically, if you want to have the triangle under the infoWindow, you can create image and put it inside the custom infoWindow and set view background as clear color.

To give shadow, you can use same techniques like you would add it to any other UIView.