Adding GMSMarker to GMSMapView Crashes on iPhone 6

I have some code that loads a map view and places a marker on it. I basically refactored my code as google example code to add GMSMarker. The app doesn't work in 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 an error in Xcode: EXC_BAD_ACCESS (code = 1, address = 0x0).

MapView is loaded on the phone when I remove a line of code marker.map = mapView_

. This is what I minified my code 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_;

      

+3


source to share





All Articles