ios - 在 iOS 上制作 MarkerinfoWindow 动画

标签 ios google-maps google-maps-sdk-ios

当我使用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/

相关文章:

ios - Swift iOS 中的 GMSCircle 不规则边框

ios - 如何在谷歌地图中拖动标记

ios - 段错误 11 修复了吗?

ios - Polidea ios-class-guard 在 XCode 7 中已死,替换它还是修复它?

ios - 单一选择在 UITableview 中不起作用

google-maps - 新的 Places API Billing 如何处理 Session?

iOS SSL 握手失败

javascript - 使用 Google Maps API 绘制 map 路径/航路点并播放路线

javascript - Google map 适合自定义范围内的标记

ios - 将 Google.Framework 包含到我的包文件中?