2014-11-06 3 views
5

Xcode 6.1에서 Google지도를 표시하는 데 문제가 있습니다.Google지도 SDK가 UIView에 제대로 표시되지 않습니까?

내 UIView 섹션에지도가 표시되도록 관리했지만 특정 좌표 대신 세계지도를 표시합니다. 여기

이 문제입니다 :

enter image description here

.H :

@interface MapViewController : UIViewController 

@property (strong, nonatomic) IBOutlet UIView *googleMapView; 

- (IBAction)mapToMain:(UIButton *)sender; 

@end 

하는 .m :

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: 32.915134 
    longitude: -117.140269 zoom: 17]; 

    GMSMapView *mapView = [GMSMapView mapWithFrame:self.googleMapView.bounds 
    camera:camera]; 
    mapView.myLocationEnabled = YES; 

    self.googleMapView = mapView; 

    GMSMarker *marker = [ [GMSMarker alloc] init]; 
    marker.position = CLLocationCoordinate2DMake(32.915134, -117.140269); 
    marker.title = @"Tet Festival 2015"; 
    marker.snippet = @"VAYA Tet"; 
    marker.map = mapView; 
} 

내가 여기에 몇 가지 제안을했다,하지만 작동하지 않았다 :

Cannot put a google maps GMSMapView in a subview of main main view?

Using the Google Maps SDK in views other than the main view

어떤 제안?

답변

3

마지막으로 제거 ...

그것을 알아 냈

[self.googleMapView addSubview:mapView]; 
0

위의 코드에 어떤 문제가 있는지 잘 모르겠습니다. 나를 위해 괜찮아 보인다. 그러나 카메라를 특정 위치로 이동합니다. 카메라에 애니메이션을 적용 할 수도 있습니다.

var newLocation = CLLocationCoordinate2DMake(latitude, longitude) 
googleMapView.animateToLocation(newLocation) 

희망은 당신을 위해서입니다.

self.googleMapView = mapView; 

교체 :

+0

나는 기본적으로 맵 마커의 위치를 ​​표시하기 위해 노력하고 있지만, 대신에 세계지도를 표시합니다. – Pangu

+0

다른 사람도 도울 수 있습니까? 나는 SO를 찾았지만 여전히 작동하지 않습니다. ( – Pangu

12

당신은 당신의 스토리 보드에있는 UIView를 추가해야합니다 ...하지만 그 후, 당신은 이 간단한 UIView를 GMSMapView로 바꾸십시오! 방금 추가 한보기를 선택하고 유틸리티 도구 모음에서 왼쪽에서 세 번째 탭을 선택하여 신원 관리자를 엽니, 아래 스크린 샷과 같이 GMSMapView의로의 UIView에서 뷰의 클래스 이름을 변경

enter image description here

콘센트는이

@property (strong, nonatomic) IBOutlet GMSMapView *mapView; 

귀하의 viewDidLoad이 될 수 같은 것이

@property (strong, nonatomic) IBOutlet UIView *googleMapView; 

될 수 없다 이 같은 :

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: 32.915134 
                  longitude: -117.140269 zoom: 17]; 

    [self.mapView animateToCameraPosition:camera]; 

    GMSMarker *marker = [ [GMSMarker alloc] init]; 
    marker.position = CLLocationCoordinate2DMake(32.915134, -117.140269); 
    marker.title = @"Tet Festival 2015"; 
    marker.snippet = @"VAYA Tet"; 
    marker.map = self.mapView; 

UPDATE

Here you have an example project (당신의 키를 삽입)

+0

고마워! 똑같은 문제가 있고 스위프트.반드시 UIView 사용자 정의 클래스를 변경해야합니다. – Roman

+0

매력처럼 작동합니다. – bittu

관련 문제