GMSMarker积分没有显示

时间:2013-11-29 22:55:00

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

我在故事板中有一个viewcontroller,其中包含一个加载googlemaps的View。然而,标记没有出现!

我做错了什么?

这是我的代码。

- (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_;
}

1 个答案:

答案 0 :(得分:0)

想出来。必须将视图添加为子视图:

[self.view addSubview:mapView_];

否则不起作用!