2017-02-13 1 views
1

Я использую карты Google Maps SDK, сначала все было нормально, но было показано как полный экран. После добавления карты в подпункт, карта больше не отображается. Я добавил точку останова на IBAction и заметил, что после прохождения:iOS Objective-C Карта Google отображается только при отладке при добавлении в подвью

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera]; 

карта отлично показано в подвид.

Thats мой код в IBAction:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12]; 

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera]; 

self.mapView1.myLocationEnabled = YES; 
[_mapView1 setMinZoom:12 maxZoom:20]; 
self.mapView1.mapType = kGMSTypeSatellite; 
self.mapView1.settings.compassButton = YES; 
_mapView1.delegate = self; 
[_mapView1 animateToViewingAngle:45]; 

// Creates a marker in the center of the map. 
GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(33.67, 35.55); 
marker.title = @"City"; 
marker.snippet = @"Country"; 
marker.map = _mapView1; 
[_subview addSubview:_mapView1]; 

thats how i want it to look like

Спасибо заранее.

+0

Пожалуйста, добавьте несколько снимков экрана, чтобы понять, что вы хотите сделать? –

+0

@SiddheshMhatre скриншот добавлен –

+0

попробуйте заменить self.mapView1 на _subview в коде IBAction –

ответ

1

Попробуйте это, он работает для меня.

GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)]; 
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12]; 

customView = [GMSMapView mapWithFrame:customView.bounds camera:camera]; 

customView.myLocationEnabled = YES; 
[customView setMinZoom:12 maxZoom:20]; 
customView.mapType = kGMSTypeSatellite; 
customView.delegate = self; 
[customView animateToViewingAngle:45]; 

// Creates a marker in the center of the map. 
GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(33.67, 35.55); 
marker.title = @"City"; 
marker.snippet = @"Country"; 
marker.map = customView; 
[self.view addSubview:customView]; 

ИЛИ

GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)]; 

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12]; 
_mapView = [GMSMapView mapWithFrame:customView.bounds camera:camera]; 

_mapView.myLocationEnabled = YES; 
[_mapView setMinZoom:12 maxZoom:20]; 
_mapView.mapType = kGMSTypeSatellite; 
_mapView.settings.compassButton = YES; 
_mapView.delegate = self; 
[_mapView animateToViewingAngle:45]; 

// Creates a marker in the center of the map. 
GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(33.67, 35.55); 
marker.title = @"City"; 
marker.snippet = @"Country"; 
marker.map = _mapView; 
[customView addSubview:_mapView]; 
[self.view addSubview:customView]; 

Также проверьте ваш _subview скрыты или нет.

+0

вы пробовали этот код? –

+0

Да, я пробовал. сначала работал отлично. –

0

Поскольку я не могу комментировать, я буду использовать этот способ попросить вас сделать некоторые вещи:

1- Добавить в breankpoint этой линии и проверьте значения _subview.bounds.

self.mapView1 = [GMSMapView mapWithFrame: _subview.bounds камера: камера];

2- Во время работы в тренажере нажмите на Debug> Просмотр Debugging> Захват Просмотр иерархии и найдите AVPlayer, проверьте свойства на правой панели.

0

При создании GMSMapView проверьте _subview.bounds.

В зависимости от времени, которое это сделано, оно может не быть настроено, и вы можете получить рамку CGRectZero.

+0

где и когда я должен его создать в первую очередь? –

+0

Попробуйте в viewDidLayoutSubviews. – CristiC

+0

То же самое ничего не изменилось :( –

Смежные вопросы