3

being a newby IOS developer, I'm really struggling to get something basic to work.

I have a need to display this kind of custom info window upon a marker click in the google maps sdk for ios.

enter image description here

Any help would be appreciated.

I've already seen the third party components, but even with them I cannot get this to display. There is always a title, snippet, left image and right image part. The real question is how do you get the gold star rating in the window, with the text next to it.

gerhard
  • 173
  • 2
  • 6
  • plz check these links, it may hep u https://github.com/grgcombs/MultiRowCalloutAnnotationView or https://github.com/jpsim/JPSThumbnailAnnotation – sbrsantanu Sep 01 '14 at 06:37
  • i've seen those links before, they are for mapkit, the key here is using google maps – gerhard Sep 01 '14 at 07:09
  • http://kevinxh.github.io/swift/custom-and-interactive-googlemaps-ios-sdk-infowindow.html this blog explains how to solve this problem. – Kevin He Nov 12 '16 at 02:10

4 Answers4

4

Make Xib as you want...set Text and image

set delegate GMSMapViewDelegate

-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{

    CustomInfoWindow *infoWindow=[[[NSBundle mainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0];  
     return infoWindow;

}

https://www.youtube.com/watch?v=ILiBXYscsyY for more help see this video..Uploded by google

Hima
  • 1,249
  • 1
  • 14
  • 18
Dipen Desai
  • 237
  • 1
  • 16
4

I was suffering from the same problem of Info window customization in GoogleMapsSdk for iOS for a lot of days, got frustrated & did it my self!

Clean, Completely customizable & Own UIControls with your custom actions code can be found on Github Right here

Happy coding :)

Nikhil Manapure
  • 3,748
  • 2
  • 30
  • 55
Naresh Reddy M
  • 1,096
  • 1
  • 10
  • 27
  • FYI,Live rendering of info window support has been added in Google maps SDK for iOS V 2+(from around this version). –  Oct 19 '16 at 16:51
2

Swift 3.0 Solution

Google Map CustomInfoWindow

//empty the default infowindow
    func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
        return UIView()
    }

    // reset custom infowindow whenever marker is tapped
    func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {

        customInfoView.removeFromSuperview()
    //    customInfoView.button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
        self.view.addSubview(customInfoView)

        // Remember to return false
        // so marker event is still handled by delegate
        return false
    }

    // let the custom infowindow follows the camera
    func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
        if (locationMarker != nil){
            let location = locationMarker.position
            customInfoView.center = mapView.projection.point(for: location)
        }
    }

    // take care of the close event
    func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
        customInfoView.removeFromSuperview()
    }
Sourabh Sharma
  • 8,222
  • 5
  • 68
  • 78
1

ended up using SMCalloutView @ https://github.com/nfarina/calloutview

gerhard
  • 173
  • 2
  • 6