I am using Google Maps SDK for iOS app. I need to customize 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 is not comming in markerInfoWindow.
I had the same problem - markerInfoWindow wouldn't get called even after setting the delegate. Ended up doing this:
- (BOOL)mapView:(GMSMapView*)mapView didTapMarker:(GMSMarker*)marker
{
[mapView setSelectedMarker:marker];
return YES;
}
setSelectedMarker will force a call on markerInfoWindow.
Ok it is solve i add mapView_.delegate = self; before marker making thanks
To Use markerInfoWindow
method for custom Callout, you also need to set its anchor using infoWindowAnchor
property.
When you create your marker set the anchor:
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = MARKER_POSITION;
marker.infoWindowAnchor = CGPointMake(0.44f, 0.45f);
marker.icon = [UIImage imageNamed:@"CustomMarkerImageName"];
then create the delegate method.
- (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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With