I'm struggling with this problem!
I want to add a google maps GMSMapView
into a UIView
that is only a portion of the main UIView
of my ViewController
.
It should be simple... I created with the storyboard a UIView
of the size I want and put it in the main UIView
.
Snippet from Interface file:
@interface MapViewController : UIViewController <CLLocationManagerDelegate>
@property(nonatomic) IBOutlet GMSMapView *mapView;
With the mapView linked with this UIView
inside the main UIView
.
What I do in the implementation:
@synthesize mapView = _mapView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:10];
_mapView = [GMSMapView mapWithFrame:_mapView.bounds camera:camera];
_mapView.myLocationEnabled = YES;
}
This should work, shouldn't it?
What I get is that my internal UIView is empty.
If I instantiate a map following google's starting guide Google Map Integration Document, it works but it assigns the map to the MAIN UIView and thats a different thing.
I tried even changing the class of my mapView in the storyboard from UIView
to GMSMapView
.
The map is showed in the inner view but it is initialized in a strange way making
- The system throwing an error saying
"Failed to make complete frame buffer"
and slowing down a lot the loading of the view (it takes 2-3 seconds on the simulator)
- The map not responding in any camera change done in the
viewDidLoad
method.
Any suggestions?
I read some posts here on StackOverflow but couldn't find a valid solution :(
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…