MSCRM and MapPoint Integration - A picture is worth a thousand words.
Posted by Ayaz Ahmad [MVP - MSCRM] on June 12, 2007
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 Web Dialog:
For any comments or suggestion do let me know. Your suggestions and comments are valuable for me. Thanks!


June 13, 2007 at 10:29 pm
Awesome work Ayaz!
I would love to do it with SharePoint too, hopefully the results are as fantastic as with CRM……..
Rehman
http://rehmangul.wordpress.com
June 13, 2007 at 10:36 pm
Hi Rehman,
MapPoint is amazing Web Service. Any application can use this and enrich with Maping features. One just need to provide valid address information to web service. Rest of Simple API will work for you.
Cheers!
Ayaz
June 17, 2007 at 6:38 am
Hi Ayaz, I was looking to integrate a CRM application with a location based system, but also make it work with a wordpress blogging system. Kind of a crazy idea, but I did not think of connecting php world with Microsoft world. I read your post, and saw that you are highly respected from the MS team, and Satya Nadella was also recommended, he was an Advisor to my previous co. I am wondering, what it would take, or is it absolutely crazy to integrate a WordPress engine or at least have it talk with or pass info with a MS Crm? Also email me privately and see if our blogging platform at http://www.mytypes.com may sound interesting to you to help with.
June 17, 2007 at 8:24 pm
Hi Vipin,
Microsoft provides Mappoint as a web service. They are plateform and language independent. Just call MapPoint API through PHP using SOAP messaging or whatever mechanism PHP engine use to access web services and utilize them. It is very much possible in PHP.
Regards,
Ayaz
November 7, 2007 at 3:40 pm
Hello!
Can you please send me the code to do this Map integration in CRM for multiple pushpins.
I can’t find full example on your site.
Thanks a lot!
Serge
November 20, 2007 at 10:27 am
Dear Ayaz,
Is it possible to provide options for a solution that allows CRM users to email contact records with multiple email addresses and be able to select the relevant email address.
Regards
Faisal
February 14, 2008 at 8:27 am
[...] on Generate Excel 2007 Sheets from MSCRM Data – OpenXML ShowFaisal Fiaz on MSCRM and MapPoint Integration - A picture is worth a thousand words.Jen on Setting Default View for Account Activities???Chris on How to pass Entity GUID and [...]
March 3, 2008 at 6:42 pm
[...] MSCRM integration with MapPoint to draw these potential customers and existing customer to Map.http://ayazahmad.wordpress.com/2007/06/12/mscrm-and-mappoint-integration-a-picture-is-worth-a-thousa… Possible MapPoint Integrations with Microsoft Dynamics CRM1. Store locators 2. Branch Finders 3. [...]
March 5, 2008 at 4:57 pm
[...] http://ayazahmad.wordpress.com/2007/06/12/mscrm-and-mappoint-integration-a-picture-is-worth-a-thousa... [...]
May 2, 2008 at 3:19 pm
Hi Ayaz,
I want to implement the mapPoint Integeration in MSCRM4.0.Could you plz help me by providing some clear sample code for it.
August 6, 2008 at 1:49 pm
I believe the best way of migrating data into Microsoft Dynamic CRM is by using SQL Integration Services (SSIS).
You can use SSIS script component to write code using the CRM SDK.
I made a tool that helps generates the DLL required to use from SSIS script component to write Microsoft SDK code. You can download this too for free from this location http://www.ssis4crm.com
You will fined there interactions of doing a simple load.
This way is supported by Microsoft (using MSCRM SDK)