I am using Google Maps in iOS Application and have implemented a custom info window for showing title of a marker.
Now, I added a button on that custom info window but my problem is that the button action method does not get called.
@interface CustomInfoWindow : UIView
@property (nonatomic,weak) IBOutlet UILabel *addressLabel;
@property(nonatomic) IBOutlet UIButton *button;
@interface viewController : UIViewController<GMSMapViewDelegate>
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
CustomInfoWindow *infoWindow = [[[NSBundle mainBundle]loadNibNamed:@"infoWindow"
infoWindow.addressLabel.text = marker.title;
[infoWindow.button addTarget:self action:@selector(ButtonPressed)
I haven't used Google Maps SDK but after following a few links, it seems what you're trying to accomplish may not be easy.
PS: This maybe Android documentation but it seems it holds true for iOS as well.
Note: The info window that is drawn is not a live view. The view is rendered as an image (using
View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call
showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
You could instead implement GMSMapViewDelegate's
-didTapInfoWindowOfMarker: delegate method to check if the infowindow was tapped.
(the drawback is that the entire infowindow becomes one button)