How to change the size of Google Map View for iOS

Asked

Viewed 77 times

0

I’m using the Google Map SDK for iOS in a project, but when using the service by default it covers the entire screen. But I need space to add some buttons on the screen.

How can I resize the map view?

Currently using the default code:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
                                                            longitude:longitude
                                                                 zoom:17];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero 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(latitude, longitude);
    marker.title = nomeCliente;
    marker.snippet = @"Detalhes";
    marker.map = mapView_;

With this code it looks like this:

inserir a descrição da imagem aqui

But I need you to stay that way:

inserir a descrição da imagem aqui

  • Mkmapview is only in the image to illustrate. I removed it as soon as I made the screen print.

1 answer

1


For this question I made the following changes to the code:

// Criei uma nova posição e novas dimensões
CGRect rect = CGRectMake(0, 0, 300, 300);


    // Create a GMSCameraPosition that tells the map to display the
    // coordinate -33.86,151.20 at zoom level 6.
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
                                                            longitude:longitude
                                                                 zoom:17];

    // Utilizei a nova posição e dimensão e usei para alterar os valores de mapView_ 
    mapView_ = [GMSMapView mapWithFrame:rect camera:camera];
    mapView_.myLocationEnabled = YES;


    //self.view = mapView_;

    [self.view addSubview:mapView_];

    // Creates a marker in the center of the map.
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(latitude, longitude);
    marker.title = nomeCliente;
    marker.snippet = @"Detalhes";
    marker.map = mapView_;

Although I managed to solve it myself, quickly, I asked the question because I had already done other tests and modifications.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.