我有一种情况,我需要一种加载具有多个叠加层的 MKMapView 的方法。此地图视图不应显示在屏幕上,我要求加载它的唯一原因是为了从地图创建图像以在其他地方使用。
我在网上浏览了一下,但我没有找到解决问题的方法。请问有人可以帮我吗?
这是我迄今为止尝试过的(没有成功)
// Load the map view
Logs_Map_ViewController *mapViewController = [[Map_ViewController alloc] initWithNibName:@"Map_ViewController" bundle:nil];
mapViewController.GPSCoordinatesToPlot = [someDictionary objectForKey:kGPSCoords];
// Take a picture of the map
UIImage *mapImage = [mapViewController convertMapToImage];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(mapImage)];
NSString *base64String = [imageData base64EncodedString];
注意:应用程序等待地图完全加载(以便正确创建图像)非常重要。