I'm having some problems displaying google maps in Xcode 6.1
I managed to get the map to display in a section of my UIView, but it displays the world map instead of at a particular coordinate.
Here is the issue:
.h:
@interface MapViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *googleMapView;
- (IBAction)mapToMain:(UIButton *)sender;
@end
.m:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: 32.915134
longitude: -117.140269 zoom: 17];
GMSMapView *mapView = [GMSMapView mapWithFrame:self.googleMapView.bounds
camera:camera];
mapView.myLocationEnabled = YES;
self.googleMapView = mapView;
GMSMarker *marker = [ [GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(32.915134, -117.140269);
marker.title = @"Tet Festival 2015";
marker.snippet = @"VAYA Tet";
marker.map = mapView;
}
I saw some suggestions here, but it didn't work:
Cannot put a google maps GMSMapView in a subview of main main view?
Using the Google Maps SDK in views other than the main view
Any suggestions?
I am not sure what is wrong with the code above. It looks fine for me. But to move the camera to certain location. You can animate the camera there as well.
Hope that it works for you.
You have to add a UIView to your Storyboard... but after that you have to turn this simple UIView into a GMSMapView! Select the view you just added and open the Identity Inspector by selecting the third tab from the left in the Utilities toolbar, change the view’s class name from UIView to GMSMapView, as shown in the screenshot below:
Your Outlet will not be like this
it will be like this
Your ViewDidLoad can be like this:
UPDATE
Here you have an example project (insert your Key)
Finally figured it out...
removed:
replaced: