iOS Google Maps SDK,无法收听GMSMarker点击事件 [英] iOS Google Maps SDK, Can't listen to GMSMarker tap event

查看:175
本文介绍了iOS Google Maps SDK,无法收听GMSMarker点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对适用于iOS的GoogleMaps SDK感到困惑...
我想在Google地图上点击GMSMarker时添加一些功能,但是它不起作用. 有什么问题吗?

I'm stuck with GoogleMaps SDK for iOS...
I want to add some features when I tap on a GMSMarker on my Google Map, but it doesn't work. Is there something wrong?

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;
}

推荐答案

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

I think you might need this, after you create the map:

mapView_.delegate = self;

这篇关于iOS Google Maps SDK,无法收听GMSMarker点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆