![](/img/trans.png)
[英]How to show a Info window in iOS Google maps without tapping on Marker?
[英]How to show all Info window in iOS Google maps without tapping on Marker?
我正在嘗試創建標記而不需要點擊。 但我不能顯示所有infoWindows。 它只顯示最后一個標記上的一個infowindow。
這是我的代碼:
- (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];
}
}
和定制Infowindow:
- (UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
CustomInforwindow *customView = [[[NSBundle mainBundle] loadNibNamed:@"CustomInforwindow" owner:self options:nil] objectAtIndex:0];
return customView;
}
您可以一次顯示一個InfoWindow。
mapView.selectedMarker = marker; this will open the infowindow for the last marker
如果要顯示多個標記,則應創建包含標記和信息窗口的標記。
希望這可以幫助。
將兩個標記放在同一個地方(兩者之間保持一定的間隙)並消除兩者之間的相互作用。 例如:
marker1.position = Locationcoorsinate2dobject;
marker2.position = Locationcoorsinate2dobject;
marker1.tappable = false;
marker2.tappable = false;
現在魔術將會發生:
marker2.icon = [UIImage imageNamed:@"yourinfowindow.png"];
marker2.groundanchor = CGPointMake(marker1.groundanchor.x, marker1.gorundanchor.y + 2.7);
希望這有助於快樂編碼:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.