3

I have code that loads a map view and places a marker on it. I have basically refactored my code to be Google sample code for adding a GMSMarker. The app runs no problem in the simulator (8.4), but when the marker code is added to the map on my iPhone 6 (marker.map = mapView_), the app crashes and I get the error in Xcode: EXC_BAD_ACCESS (code=1, address=0x0).

The mapView loads fine on the phone when I remove the marker.map = mapView_ line of code. Here is the what I have reduced my code to in viewDidLoad: below.

GMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:loc zoom:12.5];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

mapView_.settings.myLocationButton = YES;
mapView_.settings.tiltGestures = NO;
mapView_.settings.rotateGestures = NO;
mapView_.delegate = self;

dispatch_async(dispatch_get_main_queue(), ^{
    mapView_.myLocationEnabled = YES;
});

self.view = mapView_;

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = camera.target;
marker.snippet = @"Hello World";
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.map = mapView_;
Raesu
  • 310
  • 2
  • 15
  • Xcode up to date, iPhone and Simulator running 8.4, and using Google Maps SDK of iOS v 1.10.1 installed through CocoaPods. – Raesu Aug 03 '15 at 17:27
  • The app uses the GMSPlacePicker fine on the device using the longPress: delegate method (this drops a marker on the location). I made a new single view app with the above code and it runs on my phone. Is it possible my GoogleMaps sdk is corrupted? Some other conflict? I have no other pods installed. – Raesu Aug 03 '15 at 19:19
  • Tried this solution (edit Scheme to disable GPU Frame Capture but still crashes my device. http://stackoverflow.com/questions/31264537/adding-google-maps-as-subview-crashes-ios-app-with-exc-bad/31445847#31445847 – Raesu Aug 03 '15 at 21:16
  • I think `camera.target` not getting value. Refer this link : http://stackoverflow.com/questions/32043284/ios-google-maps-plotting-multiple-markers-issuesinfo-window-and-marker-repeatin/32043675#32043675 – VRAwesome Aug 18 '15 at 07:10
  • Thanks for the thought but it doesn't solve the issue. I started my app over with MapKit. I assume it was some obscure setting that got flipped somewhere in the project that was causing the crash...I ran out of patience and time trying to figure out what. – Raesu Aug 27 '15 at 20:08
  • Did you get Solution ? I also has same issue – Mohit Oct 24 '16 at 11:05
  • I never did. I believe I restarted my Xcode project. I use google maps SDK extensively now and have not seen this issue again. It could have been an issue with the specific version I was using. I also think you are better off creating these mapviews strictly in code...xibs may get wires crossed. – Raesu Nov 10 '16 at 16:05
  • Did anyone solve this? Also adding markers with images loaded from URLs ? – Mário Carvalho Jan 16 '17 at 17:01

0 Answers0