我正在使用Google地图SDK for iOS。当用户在地图中执行长按时,我试图丢弃PIN。下面的代码是我在Controller.M和.h文件中的内容。当我点击/长按(我在代码中更改它)时,我没有收到记录到控制台的任何东西。但是,地图是加载的。任何建议?

我在文档下使用了地图事件部分的代码: 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文件:

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface MapWithinPinViewController : UIViewController<GMSMapViewDelegate>

@end
.

有帮助吗?

解决方案

通过查看 iOS Google地图SDK,无法收听GMSMarker Tap Event

mapview_.delegate= self;

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top