以编程方式关闭 Google Maps iOS 中的标记信息窗口

15

我知道在Java版的Google Maps中很容易,但我不知道如何在Objective C版本的SDK中关闭信息窗口。

我正在使用这个方法:

-(void) mapView:(GMSMapView *)mapView
    didTapInfoWindowOfMarker:(id<GMSMarker>)marker {

    sharedGlobal.shouldShowPlayer = YES;

    /* adds the path to the map by decoding google's encoded string */
    [self addPath: sharedGlobal.encodedPathString];
}

我想要添加一行代码来关闭与标记相关联的信息窗口。

2个回答

39

我认为你可以使用这个:

mapView.selectedMarker = nil;

GMSMapView.h文件中selectedMarker属性的注释如下:

/**
 * The marker that is selected.  Setting this property selects a particular
 * marker, showing an info window on it.  If this property is non-nil, setting
 * it to nil deselects the marker, hiding the info window.  This property is
 * observable using KVO.
 */
@property (nonatomic, strong) id<GMSMarker> selectedMarker;

非常好的回答...谢谢 - Vijay Sanghavi

0

SWIFT

mapView.selectedMarker?.title = nil

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接