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

馋奶兔 提交于 2019-12-10 19:05:11

问题


I'm trying to create markers without tapping. But i cant display all infoWindows. It only show one infowindow on last marker.

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:

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

回答1:


you can display one InfoWindow at a time.

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.




回答2:


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 :)



来源:https://stackoverflow.com/questions/23820740/how-to-show-all-info-window-in-ios-google-maps-without-tapping-on-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!