The Microsoft Dynamics CRM Blog
News and views from the Microsoft Dynamics CRM Team

Microsoft Dynamics CRM and MapPoint Integration - A picture is worth a thousand words

Microsoft Dynamics CRM and MapPoint Integration - A picture is worth a thousand words

  • Comments 6

Microsoft Provides MapPoint Web Service to enrich application with mapping functionality. It allows you to integrate maps, driving directions, order tracking and proximity searches into a wide range of solutions.

For those of you who want to start using MapPoint for test and development purposes you can sign up for a free developer account here:

https://mappoint-css.partners.extranet.microsoft.com/MwsSignup/Eval.aspx

With a developer account, you get full access to the MapPoint Web Service APIs and staging environment, which you can use to build applications for trial, demonstration, and proof-of-concept purposes.

Overview

Microsoft Dynamics CRM Account entity already has longitude and latitude parameters for address. But mostly organizations don’t use those parameters. MapPoint web service provides FindAddress service to resolve addresses and returns longitude and latitude parameter as shown in the code snippet below.

Find Address Longitude and Latitude

FindServiceSoap FindService = new FindServiceSoap ();
FindService.Credentials = new NetworkCredential("", "");
FindService.PreAuthenticate = true;

MyAddress mAddress = new MyAddress();
mAddress = (MyAddress)addresses[i];
FindAddressSpecification spec = new FindAddressSpecification();
spec.InputAddress = new Address();
spec.InputAddress.AddressLine = mAddress.Line1;
spec.InputAddress.CountryRegion = mAddress.Country;
spec.InputAddress.Subdivision = mAddress.StateProvince;
spec.InputAddress.PrimaryCity = mAddress.City;
spec.InputAddress.PostalCode = mAddress.Postalcode;
spec.DataSourceName = "MapPoint.NA";

FindResults results = FindService.FindAddress(spec);

Populating Location and Pushpin Array

Location and pushpins objects require longitude and latitude values for address. Following code is used to populate Location and Pushpin objects of MapPoint API.

Location[] myLocation = new Location[addresses.Count];
myLocation[i] = new Location();
myLocation[i].LatLong = new LatLong();
myLocation[i].LatLong = results.Results[0].FoundLocation.LatLong;
Pushpin[] pushpins = new Pushpin [addresses.Count];
pushpins[i] = new Pushpin();
pushpins[i].PinID = "pin0";
pushpins[i].IconName = "0";
pushpins[i].Label = mAddress.Name;
pushpins[i].IconDataSource = "MapPoint.Icons";
pushpins[i].LatLong = results.Results[0].FoundLocation.LatLong;

There is no simple way to provide hyperlink at Pushpins, although Pushpin label and icon can be set to custom settings.

Getting image and automatic zoom based on the geography covered by the addresses

MapPoint Web Service provides Render Service API to automatic zoom based on the geography covered by addresses. Here is the code snippet to do this:

//Call MapPoint Render Web Service

RenderServiceSoap RenderService = new RenderServiceSoap();
RenderService.Credentials = new NetworkCredential("", "");

MapViewRepresentations mvRep = RenderService.GetBestMapView(myLocation,"MapPoint.NA");
mviews[0] = new ViewByBoundingRectangle();
mviews[0] = mvRep.ByBoundingRectangle;

MapSpecification mspec = new MapSpecification();
mspec.Options = moptions;
mspec.Views = mviews;
mspec.Pushpins = pushpins;
mspec.DataSourceName = "MapPoint.NA";
MapImage[] image = RenderService.GetMap(mspec);

So the final image can be displayed in some ASP.NET page to show in Microsoft Dynamics CRM. Please find below my integration of MapPoint web service with MSCRM.

One can select Accounts to be plotted on MapPoint and click Show Accounts Map Button at Account Entity grid toolbar.

All selected accounts will be plotted on the MapPoint in a new web dialog with Invalid addresses at the bottom.

Here is the final Image generated in new web dialogue:

Ayaz Ahmad

CRM MVP

  • That is nice.  One basic question.  Why is this not just a Feature we can turn on within the application?   This should be something what is just added on.  I have gone thru the 245 steps to get a flippen' map to show up in a tab in CRM using the Iframe, mappoint account, java script, iss web site needs to be built  and deployed via visual studio.   So to basically deploy this solutionto a company using CRM take a day or so.   When you guys could just Build in in as an object that gets turned on during install.  

    Just a rant.  

    Thanks guys for listening.

  • Microsoft Dynamics GP 9.0 has this functionality included out-of-the-box. Would have been nice to see this in MSCRM as well. Being a novice, this looks like a ton of effort.

  • Hi Ayaz,

    This is so great. Thanks for this wonderful work. How easy it would be to make this work with Microsoft Virtual earth?

    Thanks.

  • Hi

    I've got this to work with Microsoft Virtual Earth, but its a work around. What I do is, I get the lat/long or address from CRM, pass it to mappoint web service, get the point for that lat/long(address) as well as get the resultset for different points around it. Then I build the points for pushpins in xml format and save it on the web server as an xml file. Then on the aspx page, I load the points into Microsoft VE by reading teh xml file from javascript.

    This is a big work around, but it works for us. Performance wise, not too much delay, it takes less than 30 seconds to load the VE map (with 100 points).  

    Just my 2 cents...

  • Hi

    I've got this to work with Microsoft Virtual Earth, but its a work around. What I do is, I get the lat/long or address from CRM, pass it to mappoint web service, get the point for that lat/long(address) as well as get the resultset for different points around it. Then I build the points for pushpins in xml format and save it on the web server as an xml file. Then on the aspx page, I load the points into Microsoft VE by reading teh xml file from javascript.

    This is a big work around, but it works for us. Performance wise, not too much delay, it takes less than 30 seconds to load the VE map (with 100 points).  

    Just my 2 cents...

  • I'd like to introduce Marco Amoedo Martinez , a CRM MVP from Spain and our guest blogger today. Mapping

Page 1 of 1 (6 items)
Leave a Comment
  • Please add 2 and 2 and type the answer here:
  • Post