Rahul Vyas Rahul Vyas - 4 months ago 42
iOS Question

Google map ios sdk info window only appear on 2 taps

I am using google maps ios sdk.
I have created a custom xib file for info window.

The issue I am getting is whenever I tap on a marker it the google map automatically makes the marker in center and then on next tap

info window
is displayed.

What I want is the tapped marker should display
info window
on immediately instead of tap on second time

Here is the code I'm using

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

if (marker != self.pointMarker) {
if (!self.shuttleInfoWindow) {
[self initShuttleInfoWindowObject];
}

Shuttle* shuttle = (Shuttle*)marker.userData;
if (shuttle) {
[self.shuttleInfoWindow setCurrentShuttle:shuttle];

}
self.shuttleInfoWindow.isInfoWindowDisplayed = YES;
return self.shuttleInfoWindow;
}
return nil;


}


- (void)initShuttleInfoWindowObject {
self.shuttleInfoWindow = [[[NSBundle mainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0];
[self.shuttleInfoWindow setFrame:CGRectMake(0,
0,
self.shuttleInfoWindow.frame.size.width,
self.shuttleInfoWindow.frame.size.height)];
self.shuttleInfoWindow.delegate = self;
}

Answer

try writing this delegate :

- (BOOL)mapView:(GMSMapView*)mapView didTapMarker:(GMSMarker*)marker
{
    [mapview setSelectedMarker:marker];
    return YES;
}
Comments