【问题标题】:GMSMarker points not being shownGMSMarker 点未显示
【发布时间】:2014-06-14 01:42:36
【问题描述】:

我在情节提要中有一个视图控制器,其中有一个加载 googlemaps 的视图。然而,标记没有出现!

我做错了什么?

这是我的代码。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createBasicGSMView];
}

- (IBAction)AddPointButtonPressed:(id)sender {
    // Creates a marker in the center of the map.
    GMSMarker *CurrentLocationMarker = [[GMSMarker alloc] init];

    CLLocation *CurrentLocationNote = mapView_.myLocation;

    CurrentLocationMarker.position = CLLocationCoordinate2DMake(CurrentLocationNote.coordinate.latitude, CurrentLocationNote.coordinate.longitude);
    CurrentLocationMarker.title = @"Current Location";
    CurrentLocationMarker.snippet = @"This is the place to be";
    [CurrentLocationMarker setMap:mapView_];
}

- (void) createBasicGSMView{
    // Create a GMSCameraPosition that tells the map to display the
    // coordinate -33.86,151.20 at zoom level 6.
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:1];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;
    self.mapViewHolder = mapView_;

    // Creates a marker in the center of the map.
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
    marker.title = @"Sydney";
    marker.snippet = @"Australia";
    marker.map = mapView_;
}

【问题讨论】:

    标签: ios google-maps google-maps-sdk-ios


    【解决方案1】:

    想通了。必须将视图添加为子视图:

    [self.view addSubview:mapView_];
    

    否则不起作用!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-25
      • 2017-05-04
      • 1970-01-01
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多