The element I'm struggling with is when I try to capture the screen with any part of the GMSMapView (Google Maps SDK iOS). The output of UIGraphicsGetImageFromCurrentImageContext () UIImage is invisible. As a result, I found that GMSMapView is rendered using OpenGL. Knowing this, I tried to use the glReadPixels () method. The troubling thing is that I can get a screen capture of the map on the iPhone simulator just fine, but when I use the same method on a real device, it is still invisible (iOS 6).
I am wondering if someone ran into the same problem? I did my part in the investigation. I could not find anything that could affect my situation. Most of the common solutions I found said that I should update some CAEAGLLayer attributes. I assumed that GMSMapView would restrict me to searching for the appropriate level, but I was able to find and update CAEAGLLayer, as shown below:
[(CAEAGLLayer *)[[[mapView_ subviews] objectAtIndex:0] layer] setOpaque: NO];
[(CAEAGLLayer *)[[[mapView_ subviews] objectAtIndex:0] layer] setDrawableProperties:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES],kEAGLDrawablePropertyRetainedBacking,kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,nil]];
The forums recommended that by setting the OPAQUE layer attribute to NO and the backing property stored in YES, it would reduce the problem of iOS 6. He fixed it on the simulator, but not on the device.
The last fix I came across said to upgrade the main OpenGL view preserveBackBuffer to YES. This is where my technical expertise ended. I could not find where and how to update the value of the GMSMapView preserveBackBuffer. I assume this is a fix that will fix all problems with screen capture. This seems to be an exclusively problem with devices running iOS 6+.
Does anyone have a proven workaround?
source
share