以编程方式关闭标记的信息窗口谷歌地图 iOS

Posted

技术标签:

【中文标题】以编程方式关闭标记的信息窗口谷歌地图 iOS【英文标题】:Close info window of a marker programmatically google maps iOS 【发布时间】:2013-03-25 13:24:33 【问题描述】:

我知道在 Java 版本的 Google 地图中这很容易,但我不知道如何在 SDK 的目标 C 版本中关闭信息窗口。

我正在使用这种方法:

-(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];

并想添加一行来关闭与标记关联的信息窗口。

【问题讨论】:

【参考方案1】:

我认为你可以使用这个:

mapView.selectedMarker = nil;

GMSMapView.h 中 selectedMarker 属性上的 cmets 是这样说的:

/**
 * 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;

【讨论】:

回答得很好...谢谢【参考方案2】:

SWIFT

mapView.selectedMarker?.title = nil

【讨论】:

以上是关于以编程方式关闭标记的信息窗口谷歌地图 iOS的主要内容,如果未能解决你的问题,请参考以下文章