5
我正在使用帶有多個標記的Google Maps iOS SDK,它將在標記點擊上顯示標記信息窗口。下面的代碼適用於預期的地圖視圖中顯示的多個標記和標記。它還在標記點擊時顯示標記信息窗口,並在點擊時更改標記圖標。如何以編程方式點擊ios谷歌地圖標記或顯示標記的信息窗口?
-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)imarker
{
UIView *infowindow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 90, 45)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 90, 45)];
[label setFont:[UIFont fontWithName:@"TrebuchetMS-Bold" size:22]];
infowindow.layer.cornerRadius = 5;
infowindow.layer.borderWidth = 2;
label.textAlignment = NSTextAlignmentCenter;
label.text = @"Test";
label.textColor=[UIColor greenColor];
infowindow.backgroundColor=[UIColor whiteColor];
[infowindow addSubview:label];
return infowindow;
}
現在我想觸發編程方式點擊標記上的標記或顯示信息窗口。
marker = [GMSMarker markerWithPosition:position];
marker.title = @"Name";
marker.snippet = @"Test";
[self mapView:_mapView didTapMarker:marker];
[_mapView setSelectedMarker:marker];
上面的代碼不適合我。它只是移動到標記的位置不顯示信息窗口。有什麼方法可以通過編程方式點擊標記並顯示信息窗口?
新增marker.map,現在它的工作。 –