Search code examples
iosgoogle-maps-sdk-ios

iOS google maps sdk custom call out view and marker centering


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.


Solution

  • 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];