简体   繁体   English

如何在iOS谷歌地图中显示所有信息窗口而无需点击标记?

[英]How to show all Info window in iOS Google maps without tapping on Marker?

I'm trying to create markers without tapping. 我正在尝试创建标记而不需要点击。 But i cant display all infoWindows. 但我不能显示所有infoWindows。 It only show one infowindow on last marker. 它只显示最后一个标记上的一个infowindow。

Here is my code: 这是我的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableArray *markersArray = [[NSMutableArray alloc] init];
    for(int i=0; i<10; i++){
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.position = CLLocationCoordinate2DMake(latitude, longitude);
        marker.appearAnimation=YES;
        marker.opacity = 0.0;
        mapView.selectedMarker = marker;
        marker.map = mapView;
        [markersArray addObject:marker];
    }
}

and custom Infowindow: 和定制Infowindow:

- (UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
    CustomInforwindow *customView =  [[[NSBundle mainBundle] loadNibNamed:@"CustomInforwindow" owner:self options:nil] objectAtIndex:0];
    return customView;
}

you can display one InfoWindow at a time. 您可以一次显示一个InfoWindow。

mapView.selectedMarker = marker; this will open the infowindow for the last marker

If you want to show multiple markers then you should make marker that contains both the marker and the info window . 如果要显示多个标记,则应创建包含标记和信息窗口的标记。

Hope this helps. 希望这可以帮助。

Place two markers at same place (do maintain some gap in between both) and remove interaction for both. 将两个标记放在同一个地方(两者之间保持一定的间隙)并消除两者之间的相互作用。 For example: 例如:

marker1.position = Locationcoorsinate2dobject;
marker2.position = Locationcoorsinate2dobject;
marker1.tappable = false; 
marker2.tappable = false; 

Now the magic is gonna happen: 现在魔术将会发生:

marker2.icon = [UIImage imageNamed:@"yourinfowindow.png"];
marker2.groundanchor = CGPointMake(marker1.groundanchor.x, marker1.gorundanchor.y + 2‌​.7);

Hope this helps Happy coding :) 希望这有助于快乐编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不点击标记的情况下在 iOS 谷歌地图中显示信息窗口? - How to show a Info window in iOS Google maps without tapping on Marker? Google Maps iOS-点击标记以显示默认的Google路线按钮 - Google Maps iOS - Tapping on Marker to show default google directions button Google Maps在标记信息窗口iOS中显示语音气泡 - Google Maps Showing speechbubble in marker info window iOS Google Maps SDK iOS - 带UIButton的自定义标记信息窗口 - Google Maps SDK iOS - Custom marker info window with UIButton 以编程方式谷歌地图iOS的标记的关闭信息窗口 - Close info window of a marker programmatically google maps iOS 如何以编程方式点击ios谷歌地图标记或显示标记的信息窗口? - How to tap on ios google map marker programatically or show info window of marker? 如何使用AFnetworking图像缓存在iOS Google Maps中刷新标记信息窗口? - How to refresh marker info window in iOS Google maps with AFnetworking Image cache? 如何在ios上添加一个按钮到谷歌地图标记信息窗口? - How can i add a button to google maps marker info window on ios? 谷歌地图ios - 如何始终显示标记信息窗口? - Google map ios - how to keep the marker info window always displayed? 在Google地图上加载标记的自定义信息窗口时,iOS应用程序冻结 - iOS app freezes when loading custom info window for marker on Google Maps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM