【问题标题】:iOS Google Maps SDK, Can't listen to GMSMarker tap eventiOS Google Maps SDK,无法收听 GMSMarker 点击事件
【发布时间】:2013-10-10 09:45:34
【问题描述】:

我无法使用适用于 iOS 的 GoogleMaps SDK...
当我在我的谷歌地图上点击 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;
}

【问题讨论】:

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


    【解决方案1】:

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

    mapView_.delegate = self;
    

    【讨论】:

    • 工作,谢谢!我不小心把那个代码放在了错误的方法中!
    猜你喜欢
    • 2013-05-17
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    相关资源
    最近更新 更多