Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate GMSCamera zoom

I am developing iOS application including GoogleMaps. And implementation process of GoogleMaps SDK for iOS was completed yet.

But I want to know how to calculate GMSCamera zoom for showing whole route on Map.

In Apple Map, we use span, maybe. But GoogleMaps SDK doesn't have span.

Please give me advice.

like image 291
AlfaromeoCorse Avatar asked Jan 16 '13 08:01

AlfaromeoCorse


1 Answers

Actually in the current version of the SDK you can use fitBounds:

GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithPath:yourPath];
//There are several useful init methods for the GMSCoordinateBounds!
GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds];
[mapView_ moveCamera:update];

This way you let the math to Google, and I'm pretty sure they are really good at it.

like image 152
JP Illanes Avatar answered Sep 28 '22 01:09

JP Illanes