Secret Communications X016Y: Connecting MS Access to a Bing Map

Wouldn’t it be cool to be able to connect MS Access or other database to a Bing Map and use some of the cool features?  I got nothing in this blog about specifically using MS Access, however, if you want to see a blog that does connect to XML data and you are an advanced beginner or better, then go to the blog and read through: https://beyondrelational.com/blogs/dinesh/archive/2010/09/27/data-binding-in-silverlight.aspx, I am working on getting there.  Some people write blogs about things they know, I do blog entries for no good reason, sort of a stream of consciousness like Ulysses, without all of the weird sexual overtones.

Ok, my blah, blah, blah:

I think it would be cool to connect to MS Access, and it would be nice to have a clear step-by-step on how to do that, it’s not in this blog. 

Where I like the idea of the Bing Map App, let’s dig into Bing SilverLight Interactive Map Control for this blog.  And I will ignore my original statement about MS Access and come back to it in a later blog.  I just got distracted by the thought that what the heck is XAML and why does it exist, how painful.

It isn’t really painful after you stare at it for a few months, XAML is similar to the XML used in World Of Warcraft, the XML is used with the Lua code to build external applications that work with World of Warcraft.  In a similar way, XAML acts as the user interface, in this case the reason for XAML is that there are a large number of ways now that the users interface with software, so drag and drop can work, but some people like to write the interface rather do the drag and drop kind of design.  Go figure, I don’t really care, but tend to like drag and drop, but put up with the code writers.  There are just a lot of people in control of software design that are code writers, not drag and droppers.  Go figure, you need both.

Let’s go over the map control again, and again, and again, till I get it, that is why I teach, so I can learn from the method of teaching:

I opened up an ASP.NET Web Site in Visual Studio Ultimate, but you definitely use Visual Web Developer (Visual Web Dev)

Add the SilverLight Libraries using Add Reference

 

image

image

To make use of the SilverLight Interactive Map Control, you need the Bing Map SDK ID or you get this , image

The page appears to tell you where to go to get the developer account, on Nov. 8, 2010, it isn’t the correct web page, the page shown resolves to MSDN.Microsoft.com, close, but no credentials. 

To get credentials, see my blog https://blogs.msdn.com/b/devschool/archive/2010/11/05/secret-communications-x012y-using-the-bing-map-api-in-the-mobile-map-example.aspx,  (https://msdn.microsoft.com/en-us/library/ff428642.aspx)

which if I wasn’t so paranoid about any redirector, I would shorten.  Links active as of Nov. 8, 2010

Once you got your credential all set up, you can now utilize the Silverlight control, as I have discussed earlier, (and I have given up on using the cute code containers for short code snips, I start with a comment and end with a comment):

<!--- Start of Code: --->

<UserControl x:Class="SilverlightMapApp.MainPage"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
    <Grid x:Name="LayoutRoot">
        <m:Map CredentialsProvider=
            "Your credential here"
               Name="DemoMap"/>
    </Grid>

</UserControl>

<!--- End of Code --->

To work with this usercontrol (the SilverLight Interactive Map Control is a type of Usercontrol), you can place the map mode into C# control.  This is similar to using PHP, except that you have more advanced design and security management using C#. 

//Start of code

using System.Windows.Controls;
using Microsoft.Maps.MapControl;

namespace SilverlightTestApplication
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            myMap.Mode = new AerialMode();
        }
    }
}

// End of code

In Secret communications X017Y, I will go over the addition of buttons and then eventually get to the way to connect to a data source like MS Access 2010.

End of Secret Communications X016Y

NNNN