0

I may be missing something, but I followed the steps indicated at the Google Maps SDK for iOS Site, but so far I have had no success. I tried running the sample code they have at the bottom of the page, and my compiler keeps bugging me with an uncaught exception.

Here is my implementation:

@implementation ViewController {
    GMSMapView *mapView_;
}

Followed by this in the viewDidLoad:

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;

I did include line:

[GMSServices provideAPIKey:@"API Key"];

and replaced the API Key string with my actual API Key. Yet I get this at compile time.

enter image description here

I used a breakpoint, and the exception seems to originate when executing this line:

mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

enter image description here

Any of your help would very much be appreciated.

DAB
  • 93
  • 1
  • 7

1 Answers1

0

I would guess it wants a minimum frame size. I didn't see anything in the docs, but I would try this...

mapView_ = [GMSMapView mapWithFrame:CGRectMake(0,0, 200, 200) camera:camera];

Or whatever frame size you want with an actual width and hight.

Edit

After further review of your code I see

self.view = mapView_;

It is possible that mapView_ isn't actually a GMSMapView.

Edit Edit

After getting the full error log it sounds like it is an import or setup issue.

I would verify that none of the require imports got missed and that the required linker flag -ObjC was added correctly.

Hopefully that helps =)

Skyler Lauren
  • 3,792
  • 3
  • 18
  • 30
  • Can you scroll up to the top of the exception I see in your log and see why it says it is crashing? – Skyler Lauren Mar 01 '15 at 23:42
  • The reason is: [GMSMapView animateToCameraPosition:] : unrecognized selector sent to instance (and a hex numbering, I'm guessing, referring to some memory location). – DAB Mar 02 '15 at 00:04
  • And sorry for not including it, but mapView_ was instantiated at the beginning of the implementation as a GMSMapView. My bad. – DAB Mar 02 '15 at 00:06
  • @DAB Can you add that line to your question plz. It sounds like there may be some issues with how that is declared. That would at lease explain why you are getting the unrecognized selector. – Skyler Lauren Mar 02 '15 at 00:08
  • I also added a screen shot of the log. – DAB Mar 02 '15 at 00:10
  • Hmm then looking at the logs it might actually be an import/setup issue. Take a look at this http://stackoverflow.com/questions/23170851/google-maps-animatetocameraposition-ios7-issue or look at 6,7,8 of Adding the Google Maps SDK for iOS to your project here https://developers.google.com/maps/documentation/ios/start – Skyler Lauren Mar 02 '15 at 00:16
  • You are right! It's the -ObjC rather than the -objC I had on my Other Linker Flag. Make an answer out of it. – DAB Mar 02 '15 at 00:45