Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't assign a google maps map to custom view
    text
    copied!<p>So I followed <a href="https://developers.google.com/maps/documentation/ios/map?hl=sv#add_a_map" rel="nofollow">this guide</a> on how to add a Google map to an iOS application and it all works fine. But what I want to do is assign the map, not to <code>self.view</code> but a custom view I dragged out on to the storyboard inside(?) the other view, because when adding the map to <code>self.view</code> I can't add other elements, like buttons, or well, I probably can but I don't know how.</p> <p>Code:</p> <pre><code>// Start locationmanager locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.delegate = self; [locationManager startUpdatingLocation]; // Set up the startposition for the camera when the app first starts. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:59.34702 longitude:18.04053 zoom:10]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; self.view = mapView_; </code></pre> <p>So i created a <code>UIView</code> inside the view currently containing the map and ctrl dragged it to create an outlet called mapView in that <code>viewController</code>. So i changed the line of code from</p> <pre><code>self.view = _mapView; </code></pre> <p>to</p> <pre><code>self.mapView = _mapView; </code></pre> <p>but this does not seem to work at all, just blank. Both <code>self.view</code> and <code>self.mapsView</code> are instances of <code>UIView</code>, so why does this not work?</p> <p>Update:</p> <p>This is what my viewDidLoad looks like atm:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self.mapView addSubview:mapView_]; // Start locationmanager locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.delegate = self; [locationManager startUpdatingLocation]; // Standard cameraposition GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:59.34702 longitude:18.04053 zoom:10]; mapView_ = [GMSMapView mapWithFrame:self.mapView.frame camera:camera]; self.mapView = mapView_; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload