2
votes

My client need to add more information in info window in google map which is integrated in my app.So i have decided to use a scroll view as info window. I am using the methode - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker for representing my scrollview on top of the map.

This is my code:

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {


       self.propertyNameLabel.text = marker.title;

       self.addressLabel.text = marker.snippet;


      [self.scrollViewTest setContentSize:CGSizeMake(600.00, 610.00)];

      [self.searchMap addSubview:self.scrollViewTest];


      UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMoreTap)];
     tapGestureRecognizer.numberOfTapsRequired = 1;
    [self.moreLabel addGestureRecognizer:tapGestureRecognizer];
    self.moreLabel.userInteractionEnabled = YES;
    [tapGestureRecognizer release];


    return YES;

}

When I clicked on the marker my scroll view is displayed, but the scrolling is not working. I have set the content size and still its not working. Please help me out,

Thanks.

2

2 Answers

2
votes

The view that is returned from the markerInfoWindow delegate method isn't allowed to be interactive. Google Maps seems to just take a snapshot of the view and add it as an image, so buttons, scrollviews etc do not work.

The solution is in didTapInfoWindowOfMarker to create a separate view and add it as a subview to your main view (the one that also contains the mapView). This does create other complications of course, as it is not tied to the mapView in any way, so you need to manage closing it etc by yourself.

0
votes

You use the wrong delegate method to edit the info table.

This line of code [self.searchMap addSubview:self.scrollViewTest]; is added the subview into your map and not the info window.

You should use this delegate method:-

-(UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{
  //TODO: Custom your view here
  UIView * view =[[UIView alloc]init];
  return  view;
}

- (void)mapView:(GMSMapView *)mapView 
     didTapInfoWindowOfMarker:(GMSMarker *)marker{

 //TODO: Some logic to set the model that will be using after notification is posted
   [[NSNotificationCenter defaultCenter] postNotificationName:@"triggerActionLikeAButton" object:nil];
 }