0

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;
}
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256

1 Answers1

4

try writing this delegate :

- (BOOL)mapView:(GMSMapView*)mapView didTapMarker:(GMSMarker*)marker
{
    [mapview setSelectedMarker:marker];
    return YES;
}
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
Anjali Bhimani
  • 787
  • 5
  • 17
  • ok good. can you tell me how we can center the map on selected marker and then display info window. Both task in a single tap – Rahul Vyas Jul 07 '16 at 10:42
  • you can set , camera = [GMSCameraPosition cameraWithLatitude:currentLoc.coordinate.latitude longitude:currentLoc.coordinate.longitude zoom:17.0]; [_viewMap animateToCameraPosition:camera]; – Anjali Bhimani Jul 07 '16 at 10:48
  • @RahulVyas : if you have worked on VIdeos then can you please help in this : http://stackoverflow.com/questions/38242159/how-to-add-animation-on-image-change-while-create-video-using-images – Anjali Bhimani Jul 07 '16 at 11:32
  • Tried setting camera but no luck. When we center the camera then again info window opens in second tap – Rahul Vyas Jul 07 '16 at 12:16
  • we did that but we dont won't to use UIImageview – Anjali Bhimani Jul 07 '16 at 12:18
  • first write [_viewMap setSelectedMarker:markerInit]; this and then set camera position. try it please if it works – Anjali Bhimani Jul 07 '16 at 12:21