当我为 iOS SDK 使用谷歌地图时,我可以通过委托来改变 MarkerInfoWindow 的视图
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
我的问题是,当信息窗口(不是 pin aka 标记)即将显示时,我可以为它的弹出效果设置动画吗?我在这方面一无所知...我认为这是可能的,但有人可以在这里给我任何提示吗?
这是我的源示例
@interface BasicMapViewController()
@property (nonatomic, strong) GMSMapView* mapView;
@end
@implementation BasicMapViewController
@synthesize mapView;
- (void)viewDidLoad {
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
longitude:151.2086
zoom:9];
CGRect mapRect= CGRectMake(0, 0, 320, 320);
mapView= [GMSMapView mapWithFrame:mapRect camera:camera];
mapView.delegate= self;
[self.view addSubview:mapView];
UIButton* button= [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame= CGRectMake(120, 350, 100, 50);
[button addTarget:self
action:@selector(buttonClicked)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Add Pins" forState:UIControlStateNormal];
[self.view addSubview:button];
}
#pragma mark - button handler
-(void)buttonClicked
{
NSLog(@"clicked");
// Add a custom 'glow' marker around Sydney.
GMSMarker *sydneyMarker = [[GMSMarker alloc] init];
sydneyMarker.icon = [UIImage imageNamed:@"glow-marker"];
sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
sydneyMarker.appearAnimation= kGMSMarkerAnimationPop;
sydneyMarker.map = mapView;
GMSMarker *mbourneMarker = [[GMSMarker alloc] init];
mbourneMarker.icon = [UIImage imageNamed:@"glow-marker"];
mbourneMarker.position = CLLocationCoordinate2DMake(-37.814107, 144.963280);
mbourneMarker.appearAnimation= kGMSMarkerAnimationPop;
mbourneMarker.map = mapView;
}
#pragma mark - GMSMapView delegate methods
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
CustomInfoWindow* view = [[[NSBundle mainBundle] loadNibNamed:@"InfoWindowView" owner:self options:nil] objectAtIndex:0];
view.title.text= @"Sydney";
view.subtitle.text= @"Opera House";
return view;
}
-(void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker
{
NSLog(@"info window tapped!");
}
@end