Search code examples
google-maps-sdk-ios

How to setCenter mapview with location in google maps sdk for iOS


How to setCenter mapview with location in google maps sdk for iOS? With mapkit we can do setCenter:Location. How do this with google maps sdk for iOS.


Solution

  • Create a new camera with the GMSCameraPosition constructor

    + (GMSCameraPosition *)cameraWithTarget:(CLLocationCoordinate2D)target zoom:(CGFloat)zoom

    then use the method

    - (void)animateToCameraPosition:(GMSCameraPosition *)cameraPosition;
    

    You can also just use

    - (void)animateToLocation:(CLLocationCoordinate2D)location;
    

    but the previous allows you to change the zoom, bearing, and viewing angle within the camera constructor if you want more control over the final appearance of the camera.