Monday, September 7, 2009

The Technology Corner: Integrating Silverlight and Virtual Earth with Dynamics GP

Starting today, I will introduce a weekly series dedicated to explore other Microsoft technologies that may seem totally unrelated to Dynamics GP. These articles are based on experiences acquired through pet projects. These are projects that have not made it beyond my computing lab and have become a true passion of mine. My intention is to present them to you the reader with only one goal in mind: show how the use of technology can enhance user interaction with data. The articles will present practical samples of these technologies and how they could perhaps be incorporated into your Dynamics GP development efforts.

Part I: The Virtual Earth Silverlight Map Interface

Today we will explore Silverlight and Microsoft Virtual Earth.

Silverlight was originally introduced as a video streaming plug in, but has rapidly evolved into a feature-rich interactive web applications development framework. In turn, Microsoft Virtual Earth, now Bing Maps for Enterprise, is a set of controls and APIs that allow organizations to take advantage of the latest mapping technology to create unique customer experiences by delivering locally relevant information.

The project

As simple as it may sound, this project allows a user, say for example an account executive traveling to see a customer, to obtain not only geographical location information about the customer, but also view important account information on the map interface.

Getting Started

For this project you will need the following laundry list of development tools and technology components:
That's it!

For having no prior Silverlight or Virtual Earth development experience, this first part of the project went extremely smooth. Of first order, was the creation of the Silverlight Application project in Visual Studio.


After entering the project name, and clicking Ok, I was presented with the option of hosting my Silverlight application in a new Web site and to define the project type of my new Web application. These seemed like logical choices, so I sticked to the defaults. Another option (topic of a future article) is the ability to enable .NET RIA services for my Silverlight application.


Following Microsoft's definition:

Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. The RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier.

However, for this project, I was going to keep it simple and work with LINQ to SQL to provide data access to my Silverlight application.

After clicking on the OK button, the solution was setup. In reviewing the Solution Explorer, I had a Silverlight client application and a web application as part of the overall solution.


Silverlight client applications also make use of a XAML (pronounced "zamel") page to define and build user interface elements. XAML is an XML-based language that may be used to define graphical assets, user interfaces, behaviors, animations, and more. It was introduced by Microsoft as the markup language used in Windows Presentation Foundation, a desktop-oriented technology that is part of the .NET Framework 3.0. It was designed to help bridge the work between designers and developers in creating applications. In the case of the application, a MainPage.XAML was added.

Of second order, I needed to add a reference to my Microsoft Virtual Earth Map Control. Since this is part of the UI, it was clear enough that a References was needed on the Silverlight client application.


With a reference to the assembly, I could now add two lines of code -- literally -- to the XAML page to incorporate a map interface to my application: one to reference the map control assembly, and the other to give the map some startup parameters.

MainPage.XAML


<UserControl x:Class="VESilverlight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<m:Map Name="custMap" Center="41.900632,-87.629631"></m:Map>
</Grid>
</UserControl>


I then compiled the code and ran it in debug mode and to my surprise, I had a fully working map solution! Talking about productivity! Wow!


But, while I could make use of the map, this was only the beginning of the work ahead. For now, enjoy this first part. Try it out and let me know what you think.

I leave you with this MIX09 video presentation of Chris Pendleton, Virtual Earth Technical Evangelist at Microsoft, who explains the Virtual Earth Map Control in more detail.

video


Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/

No comments: