简体   繁体   中英

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;
}

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM