Creating custom info window in swift using google iOS sdk maps?

I created an xib and view controller and want to display its custom info window for the marker in swift. After searching the Internet, I found an old tutorial in OBJ-C, but that will not help me.

Thanks.

+5
source share
1 answer

You can implement markerInfoWindow method from GMSMapViewDelegate

An example implementation for displaying a custom info window in Swift:

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! { var infoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil).first! as CustomInfoWindow infoWindow.label.text = "\(marker.position.latitude) \(marker.position.longitude)" return infoWindow } 

You can visit this GitHub page for a detailed implementation.

Depending on how you want your info window to look, you can change the background color by doing infoWindow.backgroundColor = UIColor.redColor() or by changing the shape of your info window by doing infoWindow.layer.cornerRadius = 10.0f or even adding image by executing infoWindow.imageView.image = UIImage(named: "image.jpg") .

+7
source

All Articles