Local account search with Microsoft Dynamics CRM and Bing Maps

Today I finished my example implementation of a local account search with Microsoft Dynamics CRM 4.0 and Bing Maps. Therefore I used the virtual Contoso environment (CRM 4.0, Visual Studio 2008, …) and the Bing Maps AJAX API from Microsoft. The access to Bing Maps is completely realised in JavaScript. Only some database queries are done within a web service which is called from JavaScript.

First I need the geographic information for all accounts in the CRM. There are two ways to get this information. Get it automatically from the address of the account or let the user manually place the account on the map. If I want to use the address a valid one must be specified.

00 Account data

I have implemented a ASP.NET page for all map actions. You can find the implementation details in the attached source code.

The automatic positioning on the map with the address information is not always accurate.

01 Get coordinates

Therefore the user can place the account manually on the map.

02 Take center

In both ways I get the geographical information (latitude and longitude) from Bing Maps. With these two values I can calculate the x-, y- and z-coordinate for the current account (please see the source code for details).

var earthsRadius = 6371;

lambda = longBase * Math.PI / 180;
phi = latBase * Math.PI / 180;

coordxBase = earthsRadius * Math.cos(phi) * Math.cos(lambda);
coordyBase = earthsRadius * Math.cos(phi) * Math.sin(lambda);
coordzBase = earthsRadius * Math.sin(phi);

These values are saved in the CRM database for every account. With the following SQL statement I get all accounts within a specified radius around the current account. This function is placed in a web service and is called from the JavaScript of the ASP.NET page.

sql statement

To show all accounts in the proximity the user must choose a radius. All accounts are displayed with a link to open the CRM account form in a new window. To get the turn-by-turn directions to go from the current account to the selected one a corresponding button is displayed.

03 Show accounts

04 Show accounts

The turn-by-turn directions are shown below the map.

05 Get directions

This is only one way to use Microsoft Dynamics CRM with Bing Maps. Ideas are a dime a dozen.

Here you can find the complete source code.

Dieser Beitrag wurde unter CRM veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Log Out / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Log Out / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Log Out / Ändern )

Verbinde mit %s