【发布时间】:2025-12-31 03:50:15
【问题描述】:
我正在使用适用于 iOS 的 google maps sdk。当用户在地图上长按时,我试图放下一个图钉。下面的代码是我的 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 objective-c google-maps google-maps-sdk-ios