Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


MSCRM and MapPoint Integration - A picture is worth a thousand words.

Post Author: Joe D365 |

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.

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 APIs and staging environment, which you can use to build applications for trial, demonstration, and proof-of-concept purposes.

Overview

MapPoint

Microsoft Dynamics CRM Account entity already has longitude and latitude parameters for address. But mostly organizations don't use those parameters. This 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


Map Point 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.   MapPoint 
 Here is the final Image generated in Web Dialog:
MapPoint 
 For any comments or suggestion do let me know. Your suggestions and comments are valuable for me. Thanks!

 

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

PowerObjects Recommends