GMSCamera Not Centered

525 views Asked by At

I'm running into a very strange bug which causes the GMSCamera of the GMSMapView to appear off center. I have a view controller in storyboard with a GMSMapView. In the center of the map view I have an image view that is pinned to line up with the camera target at all times(this functionality is similar to the Lyft app where you pan the map around a pin and it geocodes the coordinate for your pickup location). 90% of the time when I call camera.target and get the current coordinate of the camera, I get the expected result of whichever coordinate is currently in the center of the screen. However, if I logout of my app and log back in, when the map is presented it appears as if the camera is off screen. It geocodes coordinates that are not even in view. I thought that maybe the map was growing in size randomly, but it has auto layout constraints that keep it pinned to the edges of its superview. So I don't think it has to do with that. When this bug is present, I can go to another screen and come back and the bug is gone. At this point I'm just unsure how the camera could ever become uncentered. Sorry for the wall of text, but any help is greatly appreciated.

Update: I just double checked which versions of iOS this occurs on, and I can only seem to reproduce it on iOS 7. iOS 8 works as expected. Also, here's a photo so you can see what's going on(it's a bit difficult to describe so hopefully an image helps better than my description):enter image description here

As you can see, the map is centered on a locale called Mt. Adams. However, when I ask the camera what its target is, it returns a coordinate that is towards the top left corner of the screen, under the navigation bar. If I zoom all the way and this bug is present, the distance between the center of the map viewport and the camera target will become much greater.

0

There are 0 answers