XNA and Bing Map Geocoding

 

As the Japanese struggle with massive problems, let’s chat about games. Don’t you feel a little bad about having fun right now with one of the greatest countries on the planet is having this magnitude of problems? I think that people in Japan would not like it if you used them for an excuse for any reason. These are people who can take care of themselves and do a good job of it. It is important that we all focus on success, and being successful and buying Japanese goods, that will be the best thing to do. Frankly, I hope we help the Japanese people if they ask and mind our own business the rest of the time.

So let’s talk about XNA which runs on the XBox, which is produced in Mexico. Ummm, how does that help Japan? Well Japanese semiconductors are included in the XBox, so buying the XBox helps Japan. Ok, now we are back on focus. If only this excuse would convince my wife that we should buy one of those really cool Lexus Hard Top Convertibles. 

Using XNA and Bing Maps for Geocoding initially requires a Bing Map Key, you need to go to https://www.bingmapsportal.com and sign in using your LiveID. The map key is needed for what reason? I am not sure, but my guess is so that the different types of accounts can be tracked. You can make some coin with Bing Maps, and the key might keep the Bing Map server running nicely. But that is how I view it in my little fantasy world in Southern California, if you have knowledge about the key thingie let me know. I do know you need this type of key for Facebook, Twitter, and other sites that you hit utilize a server that you don’t own.

Next, you need to download from AppHub (https://create.msdn.com ), this application:

It is a basic application that you can build on. I think a zombie game that uses real maps would be cool, and then you could have a way to get people to play that they are the zombies and other people the humans. The maps would show where the humans are and the zombies could find them. Using Nerf guns a fight could happen, then everyone gets a pizza. The cool thing about that idea is that people would get outside and have some fun together. Maybe everyone who can give blood could go over to the Red Cross and give blood, tie zombies, giving blood and play is cool.

Anyway, back to programming.

The important basic component, or more appropriately Namespace is the system.device.location. The system.device.location is defined as:

The System.Device.Location namespace allows application developers to easily access the computer's location using a single API. Location information may come from multiple providers, such as GPS, Wi-Fi triangulation, and cell phone tower triangulation. The System.Device.Location classes provide a single API to encapsulate the multiple location providers on a computer and supports seamless prioritization and transitioning between them. An application developer using this API does not need to know which location-sensing technologies are available on a particular computer and is freed from the burden of tailoring an application to a specific hardware configuration.

To use system.device.location, you would define a using statement and then you might utilize the following code:

startingCoordinate = new GeoCoordinate(47.639597, -122.12845);

Later in your code, you would use the following:

bingMapsViewer = new BingMapsViewer(BingAppKey, defaultImage, unavailableImage, startingCoordinate, 5, 15, spriteBatch);

 

That should get you started, download the application sample bing_maps and dig around in the code.  The explanation file isn’t very helpful, but that is why I am here.

More to follow.  This series of blogs will have the title starting with Bing Map Geocode: whatever I am talking about that day.

I will continue the series on the WPF exam 70-511 as well.

Dig in, I will alternate between Bing Maps on XNA and Bing Map using Web Matrix.

Also, make sure to get your bing maps key!