Search code examples
iosgoogle-mapsgoogle-maps-markersinfowindowgoogle-maps-sdk-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. 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;
}

Solution

  • 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.