I am trying to load places inside Google Map View for iOS6. How to set the frame for the Map ? Currently it is fullscreen
-(void)loadView {
GMSCameraPos
I don't think loadView
is called when you are using a xib. I haven't tried using the Google Maps SDK for iOS with a xib, as I create all of my views programmatically.
Maybe you could add your map view in viewDidLoad
? So for example:
- (void)viewDidLoad
{
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.00989
longitude:76.316142
zoom:15];
mapView_ = [GMSMapView
mapWithFrame: CGRectMake(
0, 0,
self.newView.frame.size.width, self.newView.frame.size.height)
camera: camera];
[self.newView addSubview: mapView_];
}
It's hard to say if your problem here is adding the map view or something upstream.
Have you set a breakpoint in -viewDidLoad to ensure that it gets called?
Check the bounds of newView to make sure it's what you expect. Is newView visible? Is it a subview of self.view ?
One trick you can use when trying to ensure your views are where you expect them is to set the background color to something obvious, like red, and then you can see plainly on screen if it's what you expect. If you do this and don't see a red box, then your problem isn't with maps, it's somewhere upstream in the code you haven't shown us.
Good luck.
You can try... what is working for me :)
//header file
...
@property (nonatomic, weak) IBOutlet GMSMapView *mapView;
@property (weak, nonatomic) IBOutlet UIView *subview; //viewForMap
...
implementation file
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.8683
longitude:76.2086 zoom:6
bearing:0
viewingAngle:0
];
self.mapView = [GMSMapView mapWithFrame:_subview.bounds camera:camera];
[_subview addSubview:_mapView];
Create a CGRect with the required frame dimensions and set the MapView frame with method mapWithFrame:
and then add the mapview as main subview. Below is the code which explains all. CGRect fr= CGRectMake(0, 44, 768, 960); mapView_ = [GMSMapView mapWithFrame:fr camera:camera]; mapView_.myLocationEnabled = YES; [self.view addSubview:mapView_];
You need to do like this
-(void)loadView {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.00989
longitude:76.316142
zoom:15];
mapView_ = [GMSMapView mapWithFrame:self.newView.bounds camera:camera];
[self.view addSubview:newView];
[self.newView addSubview:mapView_];
}