Skip to content

Qurat Ul Ain

  • Home
  • About
  • Technology
  • Philanthropy
  • Courses
  • Ideas & Thoughts
  • Contact
  • Profile

Google Maps Integration with Dynamics CRM

April 9, 2017 by admin
385

MS Dynamics CRM by default is integrated with Bing maps. You can add Bing maps on any entity you want. You can enable or disable the feature in the Settings > Administration > System Settings area.

But if you want to integrate Google maps in Dynamics CRM on Accounts and Contacts entities, you can do so by adding a HTML web resource on account and contact forms.

Step 01: Add HTML Web Resource

In order to add Google map HTML web resource go to Settings > Customizations > Customize the system

customization

Click on Web Resources and then New

add webresource

and fill out the form for adding a new web resource;

Name – googlemaps
Display Name – Google Maps
Type – HTML
Text Editor – Click on text editor and paste the code given below;

<html>

<head>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: new google.maps.LatLng(-26.4420246,133.281323),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, map_options)
var geocoder = new google.maps.Geocoder();
var address = window.parent.Xrm.Page.data.entity.attributes.get('address1_composite').getValue();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
map.setZoom(14);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
//alert("Geocode was not successful for the following reason: " + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div style="width: 100%; height: 100%;" id="map_canvas"></div>
</body>
</html>

googlemap

texteditor

Save – Save the Web Resource
Publish – Publish the Web Resource
Preview – In the preview you will see Australia is set as default map location for cases where Address 1 fields arent populated on a record.

preview

Step 02: Add Map on Account form

Go to Account form and click on Form in the ribbon

account

Next click on Insert in the navigation and insert a new Section on form

insert

Double click on the section and rename it to Google Map.

google-mapNext add HTML web resource in this section. Select the section and click on Webreource in the ribbon

select section

Click on Web Resource in the ribbon and search the web resource we added

search webresource

When you have found the web resource, click on Add

add

Now go to Formatting tab and extend Number of Rows for this section in which the map will be displayed and click on OK.

rows

Step 03: Publish the form

Publish the form and click on Save and Close.

publish

Refresh Account form and you will find Google Map section. If correct address has been entered in Address 1 fields then the map will present Address 1 else the map will show Australia by default.

map preview

Note: Google map HTML web resource has been taken from Warren Rapson’s blog post. You can view his post here

Post navigation

Previous Post:

Why should I use XRM?

Next Post:

Embracing Microsoft Dynamics 365 AI

7 Commments

  1. Hannes says:
    June 28, 2017 at 9:46 am

    Hey, this is really a cool integration! But: How to enable, that an ‘on-click’ leads to the full google maps webpage? That would be the cherry on the cake!

    Reply
  2. Ife says:
    September 3, 2017 at 7:15 pm

    When I preview the web resource all I get back is the HTML code not a map. Can you help figure out what I am missing. Used your code exactly as it is. thanks

    Reply
  3. Shakti Singh Rajput says:
    March 13, 2018 at 10:10 am

    If we want that the address of that particular account show that address location in map then what we do?

    Reply
    1. Shakti Singh Rajput says:
      March 13, 2018 at 10:11 am

      Please tell me as early as possible

      Reply
  4. naresh says:
    May 18, 2018 at 11:06 am

    I am trying to open this in my mobile app. But it is showing on mobile and if i click on that location it was opening on google maps. Is there any solution for this to open in mobile app.

    Reply
    1. Quratulain Ibrahim says:
      March 16, 2019 at 7:45 am

      Hi Naresh,

      Google map location when clicked will by default open in the Google Map mobile application. Do you want to see the entire within CRM?

      Reply
  5. Bas says:
    June 28, 2018 at 8:22 am

    On click of the pinpoint I would like to open navigation, could you help us with that? I am looking to do this based on the Universal cross-platform syntax.

    This way our account managers can navigate directly to the client from in app.

    Thank you in advance!

    Regards,

    Bas

    Reply

Leave a Reply Cancel reply

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

bio
Innovation evangelist; technology leader with exceptional skills in Microsoft CRM, Sales Automation, and related Customer Service trends. Applying digital technologies to better connect with a customer to provide better service, and uncover opportunities for new business at enterprise scale.

Recent Posts

  • Embracing Microsoft Dynamics 365 AI
  • Google Maps Integration with Dynamics CRM
  • Why should I use XRM?
© 2021 Qurat Ul Ain | Built using WordPress and SuperbThemes