title: GMSMapView didTapAtCoordinate gives wrong coordinates until map is panned
body: <p>I am working with a GMSMapView that I have added as a custom UITableViewCell. When I first create the map and capture an initial user tap, my coordinates are based as though the user tapped near lat/lon 0/0 -- I get values like -1.800144/-1.867676 even though my map center is set to 43.50 and -116.22 (and the map displays around those coordinates).</p>
  
  <p>However, when I move the map by panning it once, and then tapping on it, my coordinates are more along the line of what I expect. Also, if I add the following code to the GMSMapViewDelegate method mapView:idleAtCameraPosition: I get the correct coordinates the first time:</p>
  
  <pre><code>    static dispatch_once_t onceToken ;
  dispatch_once(&amp;onceToken, ^{
      GMSCameraUpdate *update = [GMSCameraUpdate setCamera:position] ;
      [mapView moveCamera:update] ;
  }) ;
  </code></pre>
  
  <p>But that seems like a hack that is hiding a more fundamental issue.</p>
  
  <p>Here is the relevant code:</p>
  
  <p>My custom table view cell creates the initial mapView in its constructor:</p>
  
  <pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  {
      self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
      if (self) {
          // Camera position is moot, just need something to instantiate the map view
          GMSCameraPosition * cameraPosition = [GMSCameraPosition cameraWithLatitude:0 longitude:0 zoom:5];
  
          GMSMapView * mapView = [GMSMapView mapWithFrame:CGRectZero camera:cameraPosition];
  
          _mapView = mapView ;
       }
      return self;
  }
  </code></pre>
  
  <p>In my view controller, I set the gestures enabled, set my delegate and my map bounds:</p>
  
  <pre><code>- (void) configureMap
  {
      [_mapView.settings setAllGesturesEnabled:YES];
      [_mapView.settings setConsumesGesturesInView:YES] ;
  
      _mapView.delegate = self ;
  
      // _userTrip has among other things, a bounds for our map
      GMSCoordinateBounds * bounds = _userTrip.bounds ;
  
      DDLogInfo(@"Trip Bounds are sw(%f:%f) ne(%f:%f)",   bounds.southWest.latitude, bounds.southWest.longitude, bounds.northEast.latitude, bounds.northEast.longitude) ;
  
      GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds];
      [_mapView moveCamera:cameraUpdate];
  }
  </code></pre>
  
  <p>My delegate for camera position:</p>
  
  <pre><code>- (void) mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position
  {
      DDLogInfo(@"User changed map size. Zoom is now set to %f", mapView.camera.zoom) ;
      /* putting this in 'fixes' the problem
      static dispatch_once_t onceToken ;
      dispatch_once(&amp;onceToken, ^{
          GMSCameraUpdate *update = [GMSCameraUpdate setCamera:position] ;
          [mapView moveCamera:update] ;
      }) ;
       */
   }
  </code></pre>
  
  <p>My delegate method for taps:</p>
  
  <pre><code>- (void) mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
  {
      DDLogInfo(@"User did tap at coordinate %f, %f", coordinate.latitude, coordinate.longitude) ;
      DDLogInfo(@"Map view center %f %f and zoom is %f",  mapView.camera.target.latitude, mapView.camera.target.longitude, mapView.camera.zoom) ;
  }
  </code></pre>
  
  <p>Sample output:</p>
  
  <pre><code>[] Trip Bounds are sw(43.409890:-116.435511) ne(43.597180:-116.023860)
  
  [] map view zoom = 10.053131
  
  [] User changed map size. Zoom is now set to 10.053131
  
  --- At this point, the map is displayed and it shows the right location based on the bounds in the log statement above. Then, when I tap on the map:
  
  [] User did tap at coordinate -0.262352, -0.900879
  
  [] Map view center 43.503608 -116.229685 and zoom is 10.053131
  
  --- As you can see above, the user coordinates are way off based on where the map thinks it is. Below, I have panned the map and then did another tap
  
  [] User changed map size. Zoom is now set to 10.053131
  
  [] User did tap at coordinate 43.447926, -116.340871
  
  [] Map view center 43.426753 -116.377271 and zoom is 10.053131
  </code></pre>
  
  <p>As you can see, the user coordinates now appear to be a valid location on the map. I have verified through the debugger that the same map instance is being referenced throughout and it has the same gestureRecognizer.</p>
  
  <p>I had a previous version of the same code that did not put the GMSMapView inside a table view cell, and it does not exhibit the same problem. So, I suspect there is an initialization issue caused by putting this in a UITableViewCell.</p>
  
  <p>Anyone run across something like this and have any idea how to fix it?</p>