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

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

我坚持使用适用于 iOS 的 GoogleMaps SDK...
我想在我的 Google map 上点击 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;
}

最佳答案

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

mapView_.delegate = self;

关于iOS Google Maps SDK,无法收听 GMSMarker 点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19163515/

相关文章:

ios - 访问另一个正在运行的应用程序的信息/状态

ios - 以内存有效的方式比较两组数据

android - 聚类在 Android 版谷歌地图中不起作用。我究竟做错了什么?

android - 信息窗口不是中心位置 Android Google Map v2

ios - 椰子足 : target has transitive dependencies that include static binaries when installing 'VialerSIPLib'

ios - 谷歌地图 iOS SDK : custom icons to be used as markers

ios - 在 iOS 中移动 GMSPolyline

google-maps-sdk-ios - 如何拦截对 iOS 版 Google Maps SDK 中标记的触摸?

ios - WebKit 转换错误转换