Im trying to run the basic iOS demo SDK code. I have created the API keyand it loads ok. Although i\'ve transfered the code from viewDidLoad to loadView the effect remains.
There is only few modification you have to do.
Then make a outlet to your class.
@IBOutlet var locationMapView: GMSMapView!
In ViewDidLoad() add the following code.
let camera = GMSCameraPosition.camera(withLatitude: 10.1518, longitude: 76.3930, zoom: 6.0)
self.locationMapView.camera = camera
let initialLocation = CLLocationCoordinate2DMake(10.1518, 76.3930)
let marker = GMSMarker(position: initialLocation)
marker.title = "Kochi"
marker.snippet = "Kerala"
marker.map = locationMapView
marker.snippet = "Kerala"
I think you may have forgotten to make the class a GMSMapView delegate. The GMSMapViewDelegate bit after the () needs to be between <>
I don't assign that delegate as well as Googles Base Code does not assign it. I have fortunetly managed to get it working. The google documentation on Google Maps states what follows:
Choose your project, rather than a specific target, and open the Build Settings tab. In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
But their example project, after my examination, has the flag set on target. Setting it on the build target within my project in my case helped and my posted code works fine.
Add -ObjC in your project's GoTo: Click on your Project->Targets->Build Setting->search(Other Linker Flags) ->Set (-ObjC) Refer the Screenshot:
I had the same error because I've mistakenly written -objC instead of -ObjC (with capital O)
if it helps someone
I think you may have forgotten to make the class a GMSMapView delegate. The GMSMapViewDelegate bit after the () needs to be between <>
@interface StructuredGeocoderViewController () GMSMapViewDelegate
@end
@implementation StructuredGeocoderViewController {
GMSMapView *_mapView;
GMSGeocoder *_geocoder;
}
- (void)viewDidLoad {
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
longitude:151.2086
zoom:12];
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
_mapView.delegate = self;
_geocoder = [[GMSGeocoder alloc] init];
self.view = _mapView;
}
When you want to submit it to the store or test flight puts the flag -ObjC in the release too