如何在谷歌地图上固定iOS?

时间:2014-02-25 14:55:19

标签: ios objective-c google-maps google-maps-sdk-ios

我正在使用谷歌地图sdk for iOS。当用户在地图中长按时,我试图放下一个引脚。下面的代码是我在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

1 个答案:

答案 0 :(得分:1)

通过查看iOS Google Maps SDK, Can't listen to GMSMarker tap event

来看出来

mapView_.delegate = self;