Hey.

I created a viewcontroller with Google maps, but I need to insert a map not full-size viewcontroller, and I did it (I added the GMSMapView class to the new view), but I need to put markers on this map. An example of my marker:

CLLocationCoordinate2D position2 = CLLocationCoordinate2DMake(59.957069, 30.323013); GMSMarker *london2 = [GMSMarker markerWithPosition:position2]; london2.title = @"my office"; london2.snippet = @"description"; london2.map = mapView_; 

Question: if I add the line self.view = mapView_; , the map is reflected on the whole screen with the markers I need, if I remove it, it is reflected without markers, but the size I need. How to fix it (make the map the right size and markers)?

 - (void)viewDidLoad { [super viewDidLoad]; self.mapView_.mapType = kGMSTypeNormal; self.mapView_.settings.compassButton = YES; self.mapView_.settings.myLocationButton = YES; self.mapView_.delegate = self; [GMSServices provideAPIKey:@"AIzaSyAob82BnXLkqTEKA675GbEveoTQZNBZst4"]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:1]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; mapView_.settings.compassButton = YES; mapView_.settings.myLocationButton = YES; //self.view = mapView_; GMSMarker *london2 = [GMSMarker markerWithPosition:position2]; london2.title = @"my office"; london2.snippet = @"description"; london2.map = mapView_; 
  • one
    //self.view = mapView_; replace with [self.view addSubview:mapView_]; What happened? - BiMaWa
  • @Bimawa mapView_.myLocationEnabled = YES; I did not touch this button at all, and it disappeared - it simply does not reflect on the screen, you do not know what could be the matter? - Goshka Tarasov
  • mapView_.myLocationEnabled = YES; Does not affect the mapview visibility - BiMaWa

1 answer 1

This line has helped a lot:

 mapView.frame = CGRectMake(YOUR_MAP_X, YOUR_MAP_Y, YOUR_MAP_WIDTH, YOUR_MAP_HEIGHT); [self.view addSubview:mapView_]; 
  • Aha, that would be my next suggestive question) - BiMaWa
  • @Vitalina ♦ mapView_.myLocationEnabled = YES; I did not touch this button at all, and it disappeared - it simply does not reflect on the screen, you do not know what could be the matter? - Goshka Tarasov