When using a Bing Maps control in an app (typically using the Bing Maps SDK), most apps need to keep their billable transactions below 50,000 /day to continue using A Basic Key for Bing Maps rather than having to obtain an Enterprise Key. Bing's terms of use specify this 50K limit, but we've found that some apps hit this limit quite easily because of how the transactions are counted.

The documentation for what constitutes a transaction is documented here: http://msdn.microsoft.com/en-us/library/ff859477.aspx. The most important part of this is where it says "Any time a session that uses Bing Maps SDK for Windows Store apps using JavaScript is started with a valid Bing Maps Key, one transaction is counted. A session begins with the load of the Bing Maps for JavaScript control into a user’s browser and includes all SOAP, REST or Spatial Data service requests that use the same Bing Maps Key until the browser is closed or the user moves to a different page." 

It's that part about "a different page" that can bite you in a Windows Store app. Simply said, if the user navigates to a page in your app that creates a Bing Maps control, then navigates away such that the page (and the control) is destroyed, that counts as a transaction. If the user navigates back to that same page again, the new control will count as another transaction.

So clearly, if you have an app with a master-detail arrangement, like a master list of restrauants or hotels from which you navigate into a details page for one location and that page includes a map, a single user could incur many transactions within a single app session.

To avoid this, you'll want to create a single Bing Maps control for the app and keep it around for the app's lifetime (you'd create multiple maps if you need multiple simultaneous maps). As the user navigates, place that control in the page (e.g. parent it into the DOM in an HTML/JS app), and be sure to de-parent the control when the user navigates away so it won't be destroyed. This way the app will only have a single Bing Maps session the whole time, and panning, zooming, and changing map styles is all part of the same session and won't incur other transactions.

There are other transactions as documented on the page linked earlier. Other Bing Maps calls (REST Locations API geocoding, REST Routes API driving directions, etc.) are non-billable after the map session starts as you need to call those services using a Bing Maps session key. Using a session key to call the other API’s will cause those subsequnt transactions to be logged as non-billable since they are part of the map session (i.e.: the calls are invoked during the map session). But do be mindful of additional billable transactions when you use advanced features.

Here is a Bing Maps article that talks about this: http://www.bing.com/blogs/site_blogs/b/maps/archive/2012/02/23/optimizing-bing-maps-platform-sessions-and-transactions-usage.aspx

Here also is documentation on the getCredentials method which you use to get the session key to use in the subsequent REST Locations API geocoding calls, REST Routes API driving directions calls, etc. to ensure they are part of the map session: http://msdn.microsoft.com/en-us/library/gg427609.aspx. (The session key is not the same as the credentials you use to create the control.)


Comments are closed