Moving the google maps compass

前端 未结 5 601
南旧
南旧 2021-01-18 07:05

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

相关标签:
5条回答
  • 2021-01-18 07:32

    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];
            }
      }
    
    0 讨论(0)
  • 2021-01-18 07:34
    -(void)viewDidAppear:(BOOL)animated{
    mapView.padding = UIEdgeInsetsMake (64,0,0,0);
    }
    

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

    0 讨论(0)
  • 2021-01-18 07:39

    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.

    0 讨论(0)
  • 2021-01-18 07:40

    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.

    0 讨论(0)
  • 2021-01-18 07:42

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

    0 讨论(0)
提交回复
热议问题