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
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];
}
}
-(void)viewDidAppear:(BOOL)animated{
mapView.padding = UIEdgeInsetsMake (64,0,0,0);
}
This Code It will move Compass Button downward in 64 pixel.
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.
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.
It is not possible to change the location of the compass button. Please file a feature request.