jspooner
jspooner

Reputation: 11315

Moving the google maps compass

The new google maps SDK for iOS now has a UI widget for displaying a compass. The only problem is I only see methods to toggle it on or off. Do you know if it's possible to change it's position on the map?

https://developers.google.com/maps/documentation/ios/map#compass

Upvotes: 6

Views: 3990

Answers (5)

Tharoth
Tharoth

Reputation: 383

-(void)viewDidAppear:(BOOL)animated{
mapView.padding = UIEdgeInsetsMake (64,0,0,0);
}

This Code It will move Compass Button downward in 64 pixel.

Upvotes: 4

Sven
Sven

Reputation: 56

The new release of the Google Maps SDK 1.5 includes a paddern property for the GMSMapView. Now it is possible to set the area where UI elements will be shown.

Upvotes: 0

Roshan Gautam
Roshan Gautam

Reputation: 5480

Here is the latest workaround which works with SDK 1.5.

- (void)moveCompassButton:(GMSMapView *) map{
    for(UIView *view in [map subviews]){
        NSRange isRange = [view.description rangeOfString:@"GMSUISettingsView"];
        if(isRange.location != NSNotFound){
            for(UIView *subview in [view subviews]){
                NSRange isRange2 = [subview.description rangeOfString:@"GMSCompassButton"];
                if(isRange2.location != NSNotFound){
                    CGRect frame = view.frame;
                    frame.origin.y = 55;
                    frame.origin.x = map.frame.size.width/2 - 10;
                    [view setFrame:frame];
                }
            }
        }
    }
}

You can call this function with your map view as a parameter and you are good to go.

Upvotes: 0

Victor Alonso Barberan
Victor Alonso Barberan

Reputation: 314

Not very orthodox but it works.

  for (UIView *view in gmMapView.subviews) {
        NSRange isRange = [view.description rangeOfString:@"GMSCompassButton"];
        if (isRange.location != NSNotFound) {
           CGRect frame = view.frame;
           frame.origin.y=55;
           frame.origin.x=gmMapView.frame.size.width/2;
           [view setFrame:frame];
        }
  }

Upvotes: 3

skarE
skarE

Reputation: 5890

It is not possible to change the location of the compass button. Please file a feature request.

Upvotes: 0

Related Questions