I'm trying to figure out the costs of loading and displaying PanoramaView
s in an iOS app using Google Maps SDK.
By the official documentation, StreetView is charged $14 per 1000 instantiations up to 100k, and $11.2 above it (with volume discounts over 500k). Here the source.
In particular, it states:
An instantiation of a panorama object occurs on iOS with the GMSPanoramaView object.
To me, both because english is not my native language and the concept I know of instantiation, is not really clear what this means.
The point is that the official documentation offers a couple methods (see here for one) to move the location and change the panorama displayed by the GMSPanoramaView
object after it is created. The only thing that the documentation states clearly is that moving to nearby panoramas by double tapping or tapping the navigation arrows is not subject to charge.
So about billing, I'm trying to understand which of these two applies:
a fixed cost is charged for every time a new GMSPanoramaView is created (e.g. let panoView = GMSPanoramaView(frame: .zero)
) , and, once created, moving the panorama to a different region and displaying it by calling the moveNearCoordinate()
method is free of charge (basically it is charged 0.014$ for each app launch, if handled properly);
the fixed cost also applies to the moveNearCoordinate()
method - so, each time the panoramaID
property of the GMSPanoramaView
is changed.
I was almost sure that the 1. case was true when a guy told me that in his app (which uses the Android SDK) he was also billed for each time the panorama was moved.
Of course if I'm asking this is because I cannot still test it by myself. Can anyone shine a light about how the billing works?
EDIT: I've found out that Google offers some free credits and I quickly set up a project to test it.
The project is built as follows:
the GMSPanoramaView object is initialized as a class variable of the main ViewController
- passing .zero
as frame
gives a warning:
private let streetView: GMSPanoramaView = {
let pano = GMSPanoramaView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
pano.camera = GMSPanoramaCamera(heading: 0, pitch: 0, zoom: 0)
return pano
}()
additional setup happens in viewDidLoad()
:
view.addSubview(streetView)
streetView.move(toPanoramaID: "random_pano_id")
frame is set equal to the VC view in viewDidLayoutSubviews()
, so full screen;
there's a UIButton
on top of the hierarchy, each time it is pressed moves the panorama by calling streetView.move(toPanoramaID: newID)
. newID
is a string variable that assumes the value of one out of 12 valid, hard-coded Street View IDs. The process is sequential, from the first ID to the twelfth, so there are no duplicate panoramas displayed.
Apparently Google Developer Console reports the requests each 4-6 hours, so I was able to do three tests. I've tried to launch the app on my iPhone, load all 12 of the panos (+ the initial one) without quitting the app, then force quit the app for each test. Here the result for each test:
This is a bit confusing, as I expected either 1 or 13 requests billed. Either something's wrong with the Maps SDK, my GMSPanoramaView
object was somehow deallocated and reinstantiated (this unlikely, since a panorama is always displayed on screen) or there's another issue I can't think of.
Again, if someone can clarify what's happening I'm grateful. Also, tips to minimize the instantiations/the costs are super appreciated.
I was able to reduce the number of charged requests to 1 per app launch by declaring the GMSPanoramaView
object as static
.