Saturday, April 28, 2012

LocationServices for Windows Phone, part 2: the basics

As stated in the previous post the framework uses  Reactive Extensions (Rx) and RestSharp as glue in order to wire up a framework that is observable, asynchronous and easy to use.

Regardless of what data parts of the framework you want to use you’ll need to reference the following three libraries (further on referred to as the “core libraries”):

  • Usoniandream.WindowsPhone.Extensions
  • Usoniandream.WindowsPhone.GeoConverter
  • Usoniandream.WindowsPhone.LocationServices

Using the various data parts of the framework is as easy as referencing the library you want to use - either one, some, or all of them. At the time of this post the data parts consist of:

  • Usoniandream.WindowsPhone.LocationServices.Bing
  • Usoniandream.WindowsPhone.LocationServices.Goteborg
  • Usoniandream.WindowsPhone.LocationServices.Nokia
  • Usoniandream.WindowsPhone.LocationServices.Stockholm
  • Usoniandream.WindowsPhone.LocationServices.Stockholm.AR

Keep in mind that you’ll need to get your own API keys for the data API’s you want to use – that is, if you want to use the Bing location functionality library you’ll need a Bing Maps API key, and so on. All API keys are added to the applications App.xaml file (see sample project for more details).

Once you’ve referenced the core libraries, any data library and set up your API key you’re set to go!

Each library holds a ServiceLayer class (both classic async with callback and a Reactive Extensions based one). Within a ServiceLayer are the methods available for each of the API’s. The list of available methods are far from complete, they’re not at all the entirety of what each API has to offer – here you’re more than welcome to contribute to the project.

It’s easy to familiarize yourself with the layout of the framework and it’s namespace structure. The main points of interest on the consumer end of the framework is the Usoniandream.WindowsPhone.LocationServices.Models namespace and the Usoniandream.WindowsPhone.LocationServies.Service namespace

Short story:

  1. Add the references needed
  2. Set the API keys needed in App.xaml
  3. Declare an instance of a servicelayer
  4. Fire away at the metods available

The framework libraries, source code and sample app are all on GitHub: https://github.com/peterdrougge/Usoniandream.WIndowsPhone.LocationServices

No comments: