It’s that easy. It’s also in the news!
It’s that easy. It’s also in the news!
Abstract:
Jerry Nixon welcomes Ian Bennett and Jim Blizzard to the show as they discuss how they integrated a Bing Map into their Windows 8 app. Tune in as they chat about the Bing Maps SDK, along with the why, how-to and lessons learned from developing with Bing Maps.
If Google was the only search engine on the internet, their motivation to improve would be weak. It’s sort of like if Windows doesn’t have competition, Microsoft’s motivation to innovate isn’t compelling. For this reason competition is good.
For technical audiences who like to search technical terms and get results from forums and tech documents, Google does a great job. But using Google makes me feel a little “dirty”. Maybe that’s just me. Still, I “Google” everyday.
However, typical consumers (like my family), get more out of Bing than Google. The integration of Facebook is a nuisance to me but they seem to love it. And the results seem tailored to consumers more than a raw dump of data – though I sort of prefer that format myself.
And because Bing is defaulted in Windows Phone and Windows 8, I love the fact that I get “points” for every Bing search I do (as well as other activities). Those rewards can be exchanged for REAL products including Xbox Microsoft Points that can be used to purchase DLC and Xbox movies.
Get it here: http://aka.ms/w8maps
So many of you developers with Windows 8 applications with maps were waiting with baited breath. Now you no longer have to wait! You can rebuild your app in RTM bits and submit to the store to be there for GA!I
SDK: Bing Maps SDK for Windows Store apps combines the power of Windows 8 and Bing™ Maps to provide an enhanced mapping experience for modern-style apps. Developers can use this Bing Maps control to incorporate the latest road maps and aerial views into a Windows Store app. This SDK includes controls for apps built using JavaScript, as well as apps built using C#, C++, and Visual Basic, and requires a Bing Maps Key for a Windows Store app.
JavaScript Developers: The Bing Maps SDK for JavaScript is based on the Bing Maps AJAX Control 7.0. See Developing a Windows Store App to learn how to use the Bing Maps AJAX Control 7.0 to add Bing Maps to your Windows Store app.
Visual Basic, C# and C++ Developers: See Getting Started with Windows Store apps.
Important note for Visual Basic, C# and C++ Developers: For your Windows Store app project to work correctly, make sure you complete the steps in Add Bing Maps to a Windows Store app after you install the SDK.
There’s no question how awesome Bing Maps is. It is loaded with innovation and tons of awesome data that now you can include in your application by using their REST based services. The services provide a lot of value to developers and their apps including data source management:
New: Bing Maps Account Center now provides the ability to manage data sources created by Data Source Management API (Bing Spatial Data Services). You can now use the Manage my data sources page to view and edit all the data sources associated with your account in one place.
But the core of the Bing Maps service is the API.
This article will be using the Locations API specifically. Using this we can leverage data from other services like Bing’s Search and plot them on a map control.
Microsoft Bing Search has a set of free, exposed REST APIs that has been very popular. It allows you to do a series of queries. But let me let the documentation do the talking:
Bing API Version 2.0 enables you to embed a flexible and powerful search engine as a custom search component in your sites and applications. The new version includes:
- HTTP endpoints with results in XML or JSON
- Enhanced support for SOAP
- A fully OpenSearch compliant RSS interface
If you are anxious to port your Windows Phone application using the Bing API, you should know that they will be discontinued on August 1, 2012. At that time, they will be ported from Bing to the Azure Data Marketplace. We’ll talk about that in a later article.
Building on Windows Phone is great, but not always easy. So, here was my situation. I had the string “Denver, Colorado”. I needed to show it on a map. To show anything on a map I just add a Pushpin. The problem is, a Pushpin requires latitude and longitude.
Fortunately, the Virtual Earth Geocoding Web Service (rebranded the Bing Maps Geocoding Web Service) is here to help. Simply create a developer account and pass the service your address string. It quickly returns every geo-coordinate you could ever need.
I stitched this together and thought I would share it with you – personally. ;) Certainly, I realize you could have figured this out on your own, I just wanted to save you time and get you started.
None of this works without a Bing Application Key. Get one free with your Windows Live Id. Just go to https://www.bingmapsportal.com, sign in, and generate a key. Here’s a snapshot of my account; see that long alphanumeric string? That’s what you need in your application.
Look, it’s totally up to you where you put your Map. You can put it full screen somewhere or in a Pivot or wherever. The panning and zooming is gesture-controlled so you might not even need any control buttons. Either way, your XAML will look something like this:
Yes, that’s it! Now, jam your Bing Application Key from Step 1 into the CredentialsProvider attribute and your map will start working. You can also inject your key in code like this:
Your Bing Application Key will work for the Geocoding service, too. But first you need to add a Service Reference to your Project. The Geocoding service will parse our address string. These services are amazing – their biggest potential in my mind is address standardization.
Use this address when you setup your reference:
http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex
After you add the service, calling it is a syntactic cluster. There’s a 1% chance you would ever figure it out without copying the code from somewhere. Here’s a great resource on MSDN. The good news is, once written you can reuse the code easily. Here’s mine:
This method is as simple as I think you can write this. It takes an address string like “123 Main Street, Conifer, CO 80433” or something as simple as “Denver, Colorado” and returns the best possible location. It is asynchronous, so it uses a callback; use my method like this:
Believe it or not, you are done. You have established your Bing account, added the Map to your Windows Phone Page, and parsed your address string to a Pushpin-ready location. Wire it all together and run it, hopefully it looks like this:
There’s so much more you can do with the Bing Map control. Look through the SDK documentation on MSDN. But hopefully this gets you started so your Phone applications are geo-cool.