I want to initialise the center of the map to a custom location. Here is the code that I use for initialization:
-(void)viewDidLoad{
[super viewDidLoad];
//mapView
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:41.0109
longitude:28.998
zoom:6];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
[self.mapView setCenter:CGPointMake(41.0109,28.998)];
}
When I run this code, I saw a map centered to the Greenwich rather than the position that I gave to the camera(41.0109,28.998).
When I debug the code and print out the position of self.mapView.camera this is the output: GMSCameraPosition 0x17742ee0: target:(41.011, 28.998) bearing:0.000 zoomLevel:6.000 viewingAngle:0.000 lookAhead:0.000
. So I successfully set the location of the camera, why does it opening with the location of Greenwich?
Edit:
Please note that, mapView is a subview (UIView) that I added to the main page and I was trying to set and modify the center location.
Here is a snapshot of my storyboard:
When I try to modify mapView, I cannot set the location of the map. However, if I use the "view" which is the main view of the window, I can successfully change the center of the map.
Why is the reason for that?
How can I set the startup position of GMSMapView?
Edit 2 The source code for this project can be found here