iOS Google Maps SDK,无法收听GMSMarker点击事件

时间:2013-10-03 15:45:45

标签: ios google-maps-markers google-maps-sdk-ios

我坚持使用适用于iOS的GoogleMaps SDK ... 我想在Google地图上点击GMSMarker时添加一些功能,但它不起作用。 有什么不对吗?

FirstController.h

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>
#import "sqlite3.h"

@interface FirstViewController : UIViewController <CLLocationManagerDelegate,
                                                  GMSMapViewDelegate>
{
    sqlite3 *db;
}

FirstController.m

[...]

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    camera = [GMSCameraPosition cameraWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude zoom:(12)];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;

    for(GMSMarker *currentMarker in _locationMarkers)
    {
        currentMarker.map = mapView_;
    }

    self.view = mapView_;
}


-(BOOL) mapView:(GMSMapView *) mapView didTapMarker:(GMSMarker *)marker
{
    NSLog(@"try");
    return YES;
}

1 个答案:

答案 0 :(得分:21)

我认为在创建地图后你可能需要这个:

mapView_.delegate = self;
相关问题