[英]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.