Search code examples
iosgoogle-mapsgmsmapview

Google Maps iOS MapView


I am trying to make my google maps map view only half of the screen. I have resized the map view to be half the screen and also changed my code so it's only the bounds of the map view which is half the screen but it still goes full screen. Anyone got a solution?

// setting up mapView
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];
    _mapView = [GMSMapView mapWithFrame:_mapView.bounds camera:camera];
    _mapView.myLocationEnabled = YES;
    self.view = _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;

    // Creates a marker in the center of the map.
    GMSMarker *marker2 = [[GMSMarker alloc] init];
    marker2.position = CLLocationCoordinate2DMake(-36.86, 151.20);
    marker2.title = @"Sydney2";
    marker2.snippet = @"Australia2";
    marker2.map = _mapView;

Thanks,

Curtis


Solution

  • You may can try to add the _mapView as a subview instead of assigning it to self.view.

    [self.view addSubview:_mapView];