Location, Location, Location... A Bing Maps Rest Wrapper for WP7
Location, location, location. No we're not talking real estate, instead mobile app development. I'm sure you've heard it a thousand times already, but location is a/the killer feature for mobile app dev. We have a powerful device with us where ever we go, and it knows (or can know with your permission) your location and with the power of services, you're near. We've just now seeing the power of location context coming into its day. Mapping and navigation is nothing compared to what we'll see in the future.
And to get you in on the ground floor, to help you focus on your app logic, and not infrastructure gunk, the XAML Ninja is here to show off some cool location code...
Are you using or thinking about using Bing Maps REST Services in your application ? Finding issues with performance with the wsdl endpoints ? Would prefer to use a REST approach ?
Well, look no further, there is now a simple way for you to do all of the above…
For those folks out there that are building location based apps for WP7 or those that are thinking about one we are very excited to announce the first release of the Bing Maps Rest API wrapper classes that have recently been added to the WP7Contrib (WP7C). Unfortunately, it has taken some time to develop mainly due to the iceberg like API. When I first had the idea a simple prototype proved that it was possible along with some shout outs to those folks on Twitter to see who was taking advantage of the services it became obvious very quickly that this was a feature people were using or wanted to use. Based on some of the feedback it was apparent that people were building their own wrappers and hand cranking the client side requests, responses and classes to hold data. This is great but I wanted a more generic and reusable set of components that all WP7 developers can take advantage of, like the majority of developers we want a simple non-intrusive mechanism for incorporating the different features that these services provide into your apps.
So, exciting news, and we are certain that this new Bing Maps REST API wrapper will help make developers lives less painful when building location based applications, we are therefore very excited to hear about any of the apps you eventually build using these. Also, if you have any suggestions or feedback on the implementation or additional features that you would find useful please contact me so that we can discuss. Over the next couple of articles I will dig into each of the services in the spikes folder of WP7C and link off to Ollie who has some deep dive articles to help supplement the introductory blogs.
This being the first post about the Wrappers I thought that we should break the ice with the most commonly used service. Location. Out of all of the services this is the simplest to call but also we would suspect the most widely used. When you combine this service with the device location based WP7C bits then you can build your geo location aware app and have it plotting to a map and moving in real-time, or you could be helping your user to find the location of an address.
In the sample for using the location service we tackle both of these scenarios.
So, I am going to jump straight in here and assume that you have either looked at the sample in the Spikes folder of the WP7 Contrib (WP7C) or you have some experience of using the Rest API provided by the Bing Maps endpoint. If you have not done this then I would suggest opening up the sample and taking a quick look at the Location View Model, its pretty straight forwards so you should be back in 10.
So let's look at the mentioned sample. First some notes on getting the BingMap app to run (at least the stuff I had to do to get it to run on my system);
Download the WP7Contrib source, http://wp7contrib.codeplex.com/SourceControl/changeset/view/67768# (click on the download button to the right... Note there will likely be a newer version... I'd say, get the latest)
If you don't have them already, install the Reactive Extensions (Rx) from https://www.microsoft.com/download/en/details.aspx?id=26649 (You'll need this for the System.Reactive.Windows.Threading reference)
When you launch the Solution, you'll see its References are not happy. Luckily NuGet is here to save the day.
Using NuGet (you DO have NuGet installed, right?), get the WP7Contrib.All package. This should fix up the references for you, getting all the WP7Contrib packages and their dependences.
I swear, NuGet really is "Magic in a Download." Anyway... once that package is installed, you're references should be much happier;
Finally I had to edit the app.xaml and remove a double entry (remember this is working source code, so when you get it, you might not have to do this...)
Now the project should run and you can start playing with it, seeing how the wrapper works, etc.
If you have the Mango Dev tools installed, you can use the new Location editor feature of the emulator too...
Press the "find" button (as in on the phone, the search/magnifying glass button). Then allow the emulator to use your location and then return to the app.
If you're thinking about using locations in your WP7 app, and would rather focus on building your app and not figuring out how to bind to and use Bing Maps, then this assembly might easily be worth a look. And while you're there I'm sure you'll want to check out all the other cool stuff in the WP7Contrib project too...
This conversation has been locked by the site admins. No new comments can be made.