سؤال

When I use the google map for iOS SDK, I can alter the view of MarkerInfoWindow by delegating

- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker

My question is can I animate the popup effect of the Info Window (not the pin a.k.a marker) when it is about to be shown? I have no clue in this respect... I think its possible but can someone provide me any tip here?

Here's my source sample

@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
هل كانت مفيدة؟

المحلول

Unfortunately it seems to be impossible in current version (1.7).

It looks like the view shown on map is the "copy" of the one you return in mapView:markerInfoWindow: Any messages you send to this view will have effect only next time you tap on a marker. Although not all the messages sent to this view seem to be delivered to final view (the one we see). E.g. you can change its frame size, but not origin (position can be set by marker's infoWindowAnchor property), you can change the layer, add subviews, but can't handle touches of its subviews (at least I couldn't hack it)..

Hope this information helps and really hope they will allow more flexibility in future versions.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top