当我使用iOS SDK的谷歌地图时,我可以通过委托(delegate)来改变MarkerInfoWindow的 View
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
我的问题是,当信息窗口(而不是图钉又名标记)即将显示时,我可以为其弹出效果设置动画吗?我在这方面没有任何线索......我认为这是可能的,但有人可以在这里给我任何提示吗?
这是我的源示例
@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
最佳答案
不幸的是,在当前版本 (1.7) 中这似乎是不可能的。
看起来 map 上显示的 View 是您在 mapView:markerInfoWindow:
中返回的 View 的“副本”:您发送到该 View 的任何消息只有在您下次点击标记。尽管并非所有发送到该 View 的消息似乎都传递到最终 View (我们看到的那个)。例如。你可以改变它的框架大小,但不能改变原点(位置可以通过标记的 infoWindowAnchor
属性设置),你可以改变层,添加 subview ,但不能处理它的 subview 的触摸(至少我无法破解它)..
希望这些信息能有所帮助,并真心希望它们能在未来的版本中提供更大的灵 active 。
关于ios - 在 iOS 上制作 MarkerinfoWindow 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19679911/