-1

I have try to add a UItoolbar on the google map, but the map is cover the toolbar.

Even i add the map view to be a subview, the map view will show nothing. Is it impossible that make a toolbar on google map?

Additional information:

This view controller (GoogleMapController) has been pushed by another View Controller

Swift Code:

var camera:GMSCameraPosition = GMSCameraPosition()
var mapView:GMSMapView = GMSMapView()

override func viewDidLoad() {
    super.viewDidLoad()

    let manager = CLLocationManager()
    if CLLocationManager.locationServicesEnabled() {
        manager.startUpdatingLocation()
    }
    if CLLocationManager.authorizationStatus() == .NotDetermined {
        manager.requestAlwaysAuthorization()
    }
   camera = GMSCameraPosition.cameraWithLatitude(lat,longitude:long, zoom:17.5, bearing:30, viewingAngle:40)
   mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)

   var marker = GMSMarker()
   marker.position = CLLocationCoordinate2DMake(lat, long)
   marker.appearAnimation = kGMSMarkerAnimationPop
   marker.title = locationName

   if let mylocation = mapView.myLocation {
       NSLog("User's location: %@", mylocation)
   } else {
       NSLog("User's location is unknown")
   }
   mapView.myLocationEnabled = true
   self.view = mapView
//     self.view.addSubview(mapView)
   let toolbar: UIToolbar = UIToolbar()
   toolbar.frame = CGRectMake(0, self.view.frame.size.height - 48, self.view.frame.size.width, 48)
   toolbar.sizeToFit()
   toolbar.backgroundColor = UIColor.redColor()
   self.view.addSubview(toolbar)
}
Jacky Shek
  • 953
  • 1
  • 11
  • 35

1 Answers1

0

I'd leverage the navigationcontroller to handle this.

GoogleMapViewController *mapVC = [[GoogleMapViewController alloc] init];
self.nc = [[UINavigationController alloc] initWithRootViewController:mapvc];
nc.navigationBar.translucent = NO;
[nc setToolbarHidden:NO];
[mapvc addCustomerToolbar];

self.window.rootViewController = self.nc;

in your mapview controller - you can either set the items to the navigation toolbar - or add a custom view.

- (void)addCustomerToolbar {
   CustomView *cv = [[CustomView alloc]init];
    [self.navigationController.toolbar addSubview:progToolbar];
}
johndpope
  • 5,035
  • 2
  • 41
  • 43
  • sorry, this is not suit my situation. Thank you for your help. The mapview controller has been push by parentController with navigation controller. – Jacky Shek Apr 15 '15 at 06:29
  • You could try self.hidesBottomBarWhenPushed = NO; self.toolbarHidden = NO; – johndpope Apr 20 '15 at 07:33