mayun
mayun

Reputation: 19

Add a custom view that includes more informations on google map markerTitle

Image

The title and snippet property of GMSMarker all can not add a custom view. Who can tell me how to do that? Thanks very much!

Upvotes: 1

Views: 90

Answers (1)

Ketan Parmar
Ketan Parmar

Reputation: 27428

You can try delegate method markerInfoWindow like,

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


UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 30)];

UILabel *label2;

UILabel *label3;

UIView *infoWindowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 250)];  //your desired frame

[infoWindowView addSubview:label1];
[infoWindowView addSubview:label2];
[infoWindowView addSubview:label3];

  return infoWindowView;
}

Called when a marker is about to become selected, and provides an optional custom info window to use for that marker if this method returns a UIView. If you change this view after this method is called, those changes will not necessarily be reflected in the rendered version. The returned UIView must not have bounds greater than 500 points on either dimension. As there is only one info window shown at any time, the returned view may be reused between other info windows. Removing the marker from the map or changing the map's selected marker during this call results in undefined behavior.

Upvotes: 1

Related Questions