2

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.

friedbunny
  • 2,421
  • 1
  • 23
  • 38
AloSwift
  • 407
  • 6
  • 24

2 Answers2

2

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.

NigelG
  • 651
  • 4
  • 7
  • I agree, best to create and manage a totally separate subview. [See my answer here](http://stackoverflow.com/a/24133509/2094275) for an example of this using SMCalloutView (instead of a scroll view). – friedbunny Jun 13 '14 at 17:14
0

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];
 }
Ricky
  • 10,485
  • 6
  • 36
  • 49
  • Previously, I used the delegate methode -(UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker. But the button in info window was not responding. That's why i used the other method and add new custom view to the map view as a subview. – AloSwift May 20 '14 at 13:09
  • You are right about button not responding inside the infoWindow. I have faced the similar problem before and have tried many different ways but still couldn't solve it. Finally, I had to use NSNotification to solve the infoWindow Tap problem. I added the code above. – Ricky May 20 '14 at 14:59