I’m using the google maps sdk for iOS. I am trying to drop a pin when the user does a long press in the map. The code below is what I have in my controller.m and .h file. When I tap/long press (I change it in the code), I’m not getting anything logged to the console. The map, however, is loading. Any advice?
I’m using code from the Maps Events section under the documentation: https://developers.google.com/maps/documentation/ios/map
#import "MapWithinPinViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#import <UIKit/UIKit.h>
@interface MapWithinPinViewController ()
@end
@implementation MapWithinPinViewController {
GMSMapView *mapView_;
}
- (void)viewDidLoad
{
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
}
- (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate {
NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);
}
@end
controller.h file:
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
@interface MapWithinPinViewController : UIViewController<GMSMapViewDelegate>
@end
Just figured it out by looking at iOS Google Maps SDK, Can't listen to GMSMarker tap event
mapView_.delegate = self;