0
votes

Hi guys I am working with Google maps sdk now, I kinda have two doubts:

Callouts:

How to customize callouts, I had a hard time trying to figure out a way to customize the existing stuff but could not. I found this though.

GMSMarkers:

I want to center the marker in the map view i.e, the marker should be in a particular position that I set and also the current zoom level should also be maintained.

I did the marker centering but now I am showing a callout from the marker and I want to center the callout to be centered.

Thanks in advance.

3

3 Answers

4
votes

For the GMSMarker question: You have to create a camera that points to the marker position and then set the mapview camera to it

somemarker = [[GMSMarker alloc] init];
somemarker.position = CLLocationCoordinate2DMake(lat, lng);
somemarker.map = mapView;

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:somemarker.position.latitude longitude:somemarker.position.longitude zoom:13];

[mapView setCamera:camera];
1
votes

You can see my SO answer here that shows how to do custom infowindows (callouts).

1
votes

You can do this by using this code -

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

NSLog(@"the post title is :%@ %@",marker.userData,marker.title);

CustomInfoWindow *view =  [[[NSBundle mainBundle] loadNibNamed:@"CustomInfoWindow" owner:self options:nil] objectAtIndex:0]; // Your Created Custom View XIB.

UILabel *theLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50,150, 50)];// Create a Custom Label and add it on the custom view.
theLabel.text = marker.title; // marker.title is the title of pin.
[view addSubview:theLabel];   
return view;
}