Reputation: 65
I'am trying to add a view to google map which both have been created using the storyboard. In order to do this, I've changed this part of the code:
mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
to this:
mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
self.mapView.myLocationEnabled = YES;
[self.view insertSubview:mapView atIndex:0];
it works, but the default "My location button" disappeared after this. Is there a way to get back the default button? I would greatly appreciate any help.
I tried this solution My location button not appearing in view (Google maps SDK, ios) but it didn't work or maybe I didn't get it correctly, if this is the only solution could you please explain it in details?
Upvotes: 0
Views: 1585
Reputation: 65
I got around this problem by creating a button from the storyboard and connect it to this action.
- (IBAction)MyLocation:(id)sender {
CLLocation *location = mapView.myLocation;
if (location) {
[mapView animateToLocation:location.coordinate];
} }
In my case, if I place the created button on the lower right/left corner still can't get it but everywhere else is just fine. (I don't know why I think because of inserting the map at index 0 or something like that).
Upvotes: 2
Reputation: 1066
Are you requesting access to location services correctly? It's done a bit different in iOS 8. Try adding the following to you Info.plist file and let me know if it works:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your message to request location usage permission goes here</string>
Upvotes: 0