Google maps markerInfowindow delegate does not call ios

I am using the Google Maps SDK for an iOS application. I need to configure markerinfowindow. I add

1) @interface MapsViewController : UIViewController GMSMapViewDelegate

2) mapView_.delegate = self;in viewdidload and

3)

 - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{
            UIView *InfoWindow = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 150, 200)];
            UILabel *nameLabel = [[UILabel alloc]init];
             nameLabel.text = @"hi";
             [InfoWindow addSubview:nameLabel];

    return InfoWindow;
}

but control does not occur in markerInfoWindow.

+4
source share
3 answers

I had the same problem - markerInfoWindow would not be called even after installing the delegate. It ended:

- (BOOL)mapView:(GMSMapView*)mapView didTapMarker:(GMSMarker*)marker
{
  [mapView setSelectedMarker:marker];
  return YES;
}

setSelectedMarker will cause a markerInfoWindow call.

+13
source

To use a method markerInfoWindowfor a custom leader, you also need to set its binding using a property infoWindowAnchor.

, :

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = MARKER_POSITION;
marker.infoWindowAnchor = CGPointMake(0.44f, 0.45f);
marker.icon = [UIImage imageNamed:@"CustomMarkerImageName"];

.

- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
  InfoWindow *view =  [[[NSBundle mainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0];
  view.name.text = @"Place Name";
  view.description.text = @"Place description";
  view.phone.text = @"123 456 789";
  view.placeImage.image = [UIImage imageNamed:@"customPlaceImage"];
  view.placeImage.transform = CGAffineTransformMakeRotation(-.08);
  return view;
}
+2

, mapView_.delegate = self;

+1

Source: https://habr.com/ru/post/1526688/


All Articles